Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

proper reference tests for zero padding tests

  • Loading branch information...
commit 3bcb08929e098e3e5907ea089bfca17c27681a11 1 parent 099b644
@substack substack authored
Showing with 20 additions and 2 deletions.
  1. +20 −2 test/buf.js
View
22 test/buf.js
@@ -143,13 +143,31 @@ exports.toBuf = function () {
[].slice.call(bigint(43135012110).toBuffer({
endian : 'little', size : 4
})),
- [ 0x0d, 0x0c, 0x0b, 0x0a, 0x00, 0x00, 0x00, 0x0e ]
+ [ 0x00, 0x00, 0x00, 0x0a, 0x0e, 0x0d, 0x0c, 0x0b ]
);
assert.eql(
[].slice.call(bigint(43135012110).toBuffer({
endian : 'big', size : 4
})),
- [ 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x00, 0x00, 0x00 ]
+ [ 0x00, 0x00, 0x00, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e ]
+ );
+};
+
+exports.zeroPad = function () {
+ var b = bigint(0x123456);
+
+ assert.eql(
+ [].slice.call(
+ b.toBuffer({ endian : 'big', size:4 })
+ ),
+ [ 0x00, 0x12, 0x34, 0x56 ]
+ );
+
+ assert.eql(
+ [].slice.call(
+ b.toBuffer({ endian : 'little', size:4 })
+ ),
+ [ 0x00, 0x56, 0x34, 0x12 ]
);
};
Please sign in to comment.
Something went wrong with that request. Please try again.