Skip to content

Commit

Permalink
fix(ulong): decode smallulong and ulong0 as normal numbers
Browse files Browse the repository at this point in the history
  • Loading branch information
mbroadst committed Jan 26, 2016
1 parent 7a5353f commit b2416a0
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 11 deletions.
4 changes: 2 additions & 2 deletions lib/types.js
Original file line number Diff line number Diff line change
Expand Up @@ -401,11 +401,11 @@ registerType('ulong', {
}, {
code: 0x53,
builder: function(val, bufb) { bufb.appendUInt8(val); },
decoder: function(buf) { return new Int64(0x0, buf.readUInt8(0)); }
decoder: function(buf) { return buf.readUInt8(0); }
}, {
code: 0x44,
builder: function(val, bufb) {},
decoder: function(buf) { return new Int64(0, 0); }
decoder: function(buf) { return 0; }
}]
});

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"jsdoc-to-markdown": "^1.2.0",
"jshint": "^2.6.0",
"mocha": "^2.1.0",
"qmf2": "^0.0.5",
"qmf2": "^0.0.6",
"stream-buffers": "^2.2.0"
},
"scripts": {},
Expand Down
4 changes: 2 additions & 2 deletions test/integration/qpid/disposition.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ describe('Disposition', function() {

test.broker.getQueue(queueName)
.then(function(queue) {
expect(queue.msgDepth.toNumber(true)).to.equal(0);
expect(queue.msgDepth).to.equal(0);
done();
});
});
Expand Down Expand Up @@ -89,7 +89,7 @@ describe('Disposition', function() {

test.broker.getQueue(queueName)
.then(function(queue) {
expect(queue.msgDepth.toNumber(true)).to.equal(0);
expect(queue.msgDepth).to.equal(0);
done();
});
});
Expand Down
8 changes: 4 additions & 4 deletions test/unit/test_codec.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ describe('Codec', function() {
expect(codec.decode(newBuffer([0x41]))[0]).to.be.true;
expect(codec.decode(newBuffer([0x42]))[0]).to.be.false;
expect(codec.decode(newBuffer([0x43]))[0]).to.eql(0);
expect(codec.decode(newBuffer([0x44]))[0]).to.eql(new Int64(0, 0));
expect(codec.decode(newBuffer([0x44]))[0]).to.eql(0);
});

it('should match longs', function() {
Expand Down Expand Up @@ -106,10 +106,10 @@ describe('Codec', function() {
var actual = codec.decode(buffer);
expect(actual[0]).to.be.an.instanceOf(DescribedType);
expect(actual[0].value).to.be.an.instanceOf(Array);
expect(actual[0].descriptor).to.eql(new Int64(0, 1));
expect(actual[0].descriptor).to.eql(0x01);
expect(actual[0].value).to.not.be.empty;
expect(actual[0].value[0]).to.be.an.instanceOf(DescribedType);
expect(actual[0].value[0].descriptor).to.eql(new Int64(0, 2));
expect(actual[0].value[0].descriptor).to.eql(0x02);
expect(actual[0].value[0].value).to.eql('VAL');
});

Expand Down Expand Up @@ -149,7 +149,7 @@ describe('Codec', function() {
0xa1, 0x00,
0x70, 0x00, 0x10, 0x00, 0x00]);
var actual = codec.decode(newBuffer(buffer));
expect(actual[0]).to.eql(new DescribedType(new Int64(0, 0x10), ['', '', 0x00100000]));
expect(actual[0]).to.eql(new DescribedType(0x10, ['', '', 0x00100000]));
});

it('should decode known type (AMQPError) from described type', function() {
Expand Down
4 changes: 2 additions & 2 deletions test/unit/test_types.js
Original file line number Diff line number Diff line change
Expand Up @@ -511,12 +511,12 @@ describe('Types', function() {
},
{
name: 'smallulong', value: buf([0x53, 0x01]),
expectedOutput: new Int64(0x00000000, 0x00000001)
expectedOutput: 0x01
},
{
name: 'ulong0',
value: buf([0x44]),
expectedOutput: new Int64(0x00000000, 0x00000000)
expectedOutput: 0
},
{ name: 'byte', value: buf([0x51, 0x01]), expectedOutput: 1 },
{ name: 'short', value: buf([0x61, 0x00, 0x01]), expectedOutput: 1 },
Expand Down

0 comments on commit b2416a0

Please sign in to comment.