|
@ -19,6 +19,19 @@ function test8() { |
|
|
ASSERT.throws(function() { |
|
|
ASSERT.throws(function() { |
|
|
buffer.writeInt8(0xabc, 0); |
|
|
buffer.writeInt8(0xabc, 0); |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
/* Make sure we handle min/max correctly */ |
|
|
|
|
|
buffer.writeInt8(0x7f, 0); |
|
|
|
|
|
buffer.writeInt8(-0x80, 1); |
|
|
|
|
|
|
|
|
|
|
|
ASSERT.equal(0x7f, buffer[0]); |
|
|
|
|
|
ASSERT.equal(0x80, buffer[1]); |
|
|
|
|
|
ASSERT.throws(function() { |
|
|
|
|
|
buffer.writeInt8(0x7f + 1, 0); |
|
|
|
|
|
}); |
|
|
|
|
|
ASSERT.throws(function() { |
|
|
|
|
|
buffer.writeInt8(-0x80 - 1, 0); |
|
|
|
|
|
}); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -45,6 +58,33 @@ function test16() { |
|
|
ASSERT.equal(0x71, buffer[2]); |
|
|
ASSERT.equal(0x71, buffer[2]); |
|
|
ASSERT.equal(0x71, buffer[3]); |
|
|
ASSERT.equal(0x71, buffer[3]); |
|
|
ASSERT.equal(0xf9, buffer[4]); |
|
|
ASSERT.equal(0xf9, buffer[4]); |
|
|
|
|
|
|
|
|
|
|
|
/* Make sure we handle min/max correctly */ |
|
|
|
|
|
buffer.writeInt16BE(0x7fff, 0); |
|
|
|
|
|
buffer.writeInt16BE(-0x8000, 2); |
|
|
|
|
|
ASSERT.equal(0x7f, buffer[0]); |
|
|
|
|
|
ASSERT.equal(0xff, buffer[1]); |
|
|
|
|
|
ASSERT.equal(0x80, buffer[2]); |
|
|
|
|
|
ASSERT.equal(0x00, buffer[3]); |
|
|
|
|
|
ASSERT.throws(function() { |
|
|
|
|
|
buffer.writeInt16BE(0x7fff + 1, 0); |
|
|
|
|
|
}); |
|
|
|
|
|
ASSERT.throws(function() { |
|
|
|
|
|
buffer.writeInt16BE(-0x8000 - 1, 0); |
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
buffer.writeInt16LE(0x7fff, 0); |
|
|
|
|
|
buffer.writeInt16LE(-0x8000, 2); |
|
|
|
|
|
ASSERT.equal(0xff, buffer[0]); |
|
|
|
|
|
ASSERT.equal(0x7f, buffer[1]); |
|
|
|
|
|
ASSERT.equal(0x00, buffer[2]); |
|
|
|
|
|
ASSERT.equal(0x80, buffer[3]); |
|
|
|
|
|
ASSERT.throws(function() { |
|
|
|
|
|
buffer.writeInt16LE(0x7fff + 1, 0); |
|
|
|
|
|
}); |
|
|
|
|
|
ASSERT.throws(function() { |
|
|
|
|
|
buffer.writeInt16LE(-0x8000 - 1, 0); |
|
|
|
|
|
}); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -83,6 +123,41 @@ function test32() { |
|
|
ASSERT.equal(0xfe, buffer[5]); |
|
|
ASSERT.equal(0xfe, buffer[5]); |
|
|
ASSERT.equal(0xff, buffer[6]); |
|
|
ASSERT.equal(0xff, buffer[6]); |
|
|
ASSERT.equal(0xcf, buffer[7]); |
|
|
ASSERT.equal(0xcf, buffer[7]); |
|
|
|
|
|
|
|
|
|
|
|
/* Make sure we handle min/max correctly */ |
|
|
|
|
|
buffer.writeInt32BE(0x7fffffff, 0); |
|
|
|
|
|
buffer.writeInt32BE(-0x80000000, 4); |
|
|
|
|
|
ASSERT.equal(0x7f, buffer[0]); |
|
|
|
|
|
ASSERT.equal(0xff, buffer[1]); |
|
|
|
|
|
ASSERT.equal(0xff, buffer[2]); |
|
|
|
|
|
ASSERT.equal(0xff, buffer[3]); |
|
|
|
|
|
ASSERT.equal(0x80, buffer[4]); |
|
|
|
|
|
ASSERT.equal(0x00, buffer[5]); |
|
|
|
|
|
ASSERT.equal(0x00, buffer[6]); |
|
|
|
|
|
ASSERT.equal(0x00, buffer[7]); |
|
|
|
|
|
ASSERT.throws(function() { |
|
|
|
|
|
buffer.writeInt32BE(0x7fffffff + 1, 0); |
|
|
|
|
|
}); |
|
|
|
|
|
ASSERT.throws(function() { |
|
|
|
|
|
buffer.writeInt32BE(-0x80000000 - 1, 0); |
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
buffer.writeInt32LE(0x7fffffff, 0); |
|
|
|
|
|
buffer.writeInt32LE(-0x80000000, 4); |
|
|
|
|
|
ASSERT.equal(0xff, buffer[0]); |
|
|
|
|
|
ASSERT.equal(0xff, buffer[1]); |
|
|
|
|
|
ASSERT.equal(0xff, buffer[2]); |
|
|
|
|
|
ASSERT.equal(0x7f, buffer[3]); |
|
|
|
|
|
ASSERT.equal(0x00, buffer[4]); |
|
|
|
|
|
ASSERT.equal(0x00, buffer[5]); |
|
|
|
|
|
ASSERT.equal(0x00, buffer[6]); |
|
|
|
|
|
ASSERT.equal(0x80, buffer[7]); |
|
|
|
|
|
ASSERT.throws(function() { |
|
|
|
|
|
buffer.writeInt32LE(0x7fffffff + 1, 0); |
|
|
|
|
|
}); |
|
|
|
|
|
ASSERT.throws(function() { |
|
|
|
|
|
buffer.writeInt32LE(-0x80000000 - 1, 0); |
|
|
|
|
|
}); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|