From: Feross Aboukhadijeh Date: Fri, 29 Apr 2016 08:40:21 +0000 (+0200) Subject: sync node.js buffer tests X-Git-Url: https://zoso.dev/?a=commitdiff_plain;h=5c46ca940c686f51052466eb2e8d4c1db9c819f6;p=buffer.git sync node.js buffer tests --- diff --git a/test/node/test-buffer-alloc.js b/test/node/test-buffer-alloc.js index 9bbe390..74c2515 100644 --- a/test/node/test-buffer-alloc.js +++ b/test/node/test-buffer-alloc.js @@ -34,7 +34,9 @@ assert.strictEqual(0, d.length); var ui32 = new Uint32Array(4).fill(42); var e = Buffer.from(ui32); -assert.deepEqual(ui32, e); +for (var [index, value] of e.entries()) { + assert.strictEqual(value, ui32[index]); +} // First check Buffer#fill() works as expected. @@ -465,32 +467,32 @@ for (var i = 0; i < Buffer.byteLength(utf8String); i++) { assert.equal(d[0], 23); assert.equal(d[1], 42); assert.equal(d[2], 255); - assert.deepEqual(d, Buffer.from(d)); + assert.deepStrictEqual(d, Buffer.from(d)); } { var e = Buffer.from('über'); // console.error('uber: \'%s\'', e.toString()); - assert.deepEqual(e, Buffer.from([195, 188, 98, 101, 114])); + assert.deepStrictEqual(e, Buffer.from([195, 188, 98, 101, 114])); } { var f = Buffer.from('über', 'ascii'); // console.error('f.length: %d (should be 4)', f.length); - assert.deepEqual(f, Buffer.from([252, 98, 101, 114])); + assert.deepStrictEqual(f, Buffer.from([252, 98, 101, 114])); } ['ucs2', 'ucs-2', 'utf16le', 'utf-16le'].forEach(function(encoding) { { var f = Buffer.from('über', encoding); // console.error('f.length: %d (should be 8)', f.length); - assert.deepEqual(f, Buffer.from([252, 0, 98, 0, 101, 0, 114, 0])); + assert.deepStrictEqual(f, Buffer.from([252, 0, 98, 0, 101, 0, 114, 0])); } { var f = Buffer.from('привет', encoding); // console.error('f.length: %d (should be 12)', f.length); - assert.deepEqual(f, + assert.deepStrictEqual(f, Buffer.from([63, 4, 64, 4, 56, 4, 50, 4, 53, 4, 66, 4])); assert.equal(f.toString(encoding), 'привет'); } @@ -501,23 +503,23 @@ for (var i = 0; i < Buffer.byteLength(utf8String); i++) { var size = f.write('あいうえお', encoding); // console.error('bytes written to buffer: %d (should be 4)', size); assert.equal(size, 4); - assert.deepEqual(f, Buffer.from([0x42, 0x30, 0x44, 0x30, 0x00])); + assert.deepStrictEqual(f, Buffer.from([0x42, 0x30, 0x44, 0x30, 0x00])); } }); { var f = Buffer.from('\uD83D\uDC4D', 'utf-16le'); // THUMBS UP SIGN (U+1F44D) assert.equal(f.length, 4); - assert.deepEqual(f, Buffer.from('3DD84DDC', 'hex')); + assert.deepStrictEqual(f, Buffer.from('3DD84DDC', 'hex')); } var arrayIsh = {0: 0, 1: 1, 2: 2, 3: 3, length: 4}; var g = Buffer.from(arrayIsh); -assert.deepEqual(g, Buffer.from([0, 1, 2, 3])); +assert.deepStrictEqual(g, Buffer.from([0, 1, 2, 3])); var strArrayIsh = {0: '0', 1: '1', 2: '2', 3: '3', length: 4}; g = Buffer.from(strArrayIsh); -assert.deepEqual(g, Buffer.from([0, 1, 2, 3])); +assert.deepStrictEqual(g, Buffer.from([0, 1, 2, 3])); // @@ -528,10 +530,10 @@ assert.equal('TWFu', (Buffer.from('Man')).toString('base64')); { // test that regular and URL-safe base64 both work var expected = [0xff, 0xff, 0xbe, 0xff, 0xef, 0xbf, 0xfb, 0xef, 0xff]; - assert.deepEqual(Buffer.from('//++/++/++//', 'base64'), - Buffer.from(expected)); - assert.deepEqual(Buffer.from('__--_--_--__', 'base64'), - Buffer.from(expected)); + assert.deepStrictEqual(Buffer.from('//++/++/++//', 'base64'), + Buffer.from(expected)); + assert.deepStrictEqual(Buffer.from('__--_--_--__', 'base64'), + Buffer.from(expected)); } { @@ -645,18 +647,30 @@ assert.equal(Buffer.from('KioqKioqKioqKioqKioqKioqKio', 'base64').toString(), '********************'); // handle padding graciously, multiple-of-4 or not -assert.equal(Buffer.from('72INjkR5fchcxk9+VgdGPFJDxUBFR5/rMFsghgxADiw==', - 'base64').length, 32); -assert.equal(Buffer.from('72INjkR5fchcxk9+VgdGPFJDxUBFR5/rMFsghgxADiw=', - 'base64').length, 32); -assert.equal(Buffer.from('72INjkR5fchcxk9+VgdGPFJDxUBFR5/rMFsghgxADiw', - 'base64').length, 32); -assert.equal(Buffer.from('w69jACy6BgZmaFvv96HG6MYksWytuZu3T1FvGnulPg==', - 'base64').length, 31); -assert.equal(Buffer.from('w69jACy6BgZmaFvv96HG6MYksWytuZu3T1FvGnulPg=', - 'base64').length, 31); -assert.equal(Buffer.from('w69jACy6BgZmaFvv96HG6MYksWytuZu3T1FvGnulPg', - 'base64').length, 31); +assert.equal( + Buffer.from('72INjkR5fchcxk9+VgdGPFJDxUBFR5/rMFsghgxADiw==', 'base64').length, + 32 +); +assert.equal( + Buffer.from('72INjkR5fchcxk9+VgdGPFJDxUBFR5/rMFsghgxADiw=', 'base64').length, + 32 +); +assert.equal( + Buffer.from('72INjkR5fchcxk9+VgdGPFJDxUBFR5/rMFsghgxADiw', 'base64').length, + 32 +); +assert.equal( + Buffer.from('w69jACy6BgZmaFvv96HG6MYksWytuZu3T1FvGnulPg==', 'base64').length, + 31 +); +assert.equal( + Buffer.from('w69jACy6BgZmaFvv96HG6MYksWytuZu3T1FvGnulPg=', 'base64').length, + 31 +); +assert.equal( + Buffer.from('w69jACy6BgZmaFvv96HG6MYksWytuZu3T1FvGnulPg', 'base64').length, + 31 +); // This string encodes single '.' character in UTF-16 var dot = Buffer.from('//4uAA==', 'base64'); @@ -1023,7 +1037,7 @@ Buffer.from(Buffer.allocUnsafe(0), 0, 0); assert.equal(string, '{"type":"Buffer","data":[116,101,115,116]}'); - assert.deepEqual(buffer, JSON.parse(string, function(key, value) { + assert.deepStrictEqual(buffer, JSON.parse(string, function(key, value) { return value && value.type === 'Buffer' ? Buffer.from(value.data) : value; @@ -1169,92 +1183,92 @@ assert.throws(function() { (function() { var buf = Buffer.allocUnsafe(3); buf.writeUIntLE(0x123456, 0, 3); - assert.deepEqual(buf.toJSON().data, [0x56, 0x34, 0x12]); + assert.deepStrictEqual(buf.toJSON().data, [0x56, 0x34, 0x12]); assert.equal(buf.readUIntLE(0, 3), 0x123456); buf = Buffer.allocUnsafe(3); buf.writeUIntBE(0x123456, 0, 3); - assert.deepEqual(buf.toJSON().data, [0x12, 0x34, 0x56]); + assert.deepStrictEqual(buf.toJSON().data, [0x12, 0x34, 0x56]); assert.equal(buf.readUIntBE(0, 3), 0x123456); buf = Buffer.allocUnsafe(3); buf.writeIntLE(0x123456, 0, 3); - assert.deepEqual(buf.toJSON().data, [0x56, 0x34, 0x12]); + assert.deepStrictEqual(buf.toJSON().data, [0x56, 0x34, 0x12]); assert.equal(buf.readIntLE(0, 3), 0x123456); buf = Buffer.allocUnsafe(3); buf.writeIntBE(0x123456, 0, 3); - assert.deepEqual(buf.toJSON().data, [0x12, 0x34, 0x56]); + assert.deepStrictEqual(buf.toJSON().data, [0x12, 0x34, 0x56]); assert.equal(buf.readIntBE(0, 3), 0x123456); buf = Buffer.allocUnsafe(3); buf.writeIntLE(-0x123456, 0, 3); - assert.deepEqual(buf.toJSON().data, [0xaa, 0xcb, 0xed]); + assert.deepStrictEqual(buf.toJSON().data, [0xaa, 0xcb, 0xed]); assert.equal(buf.readIntLE(0, 3), -0x123456); buf = Buffer.allocUnsafe(3); buf.writeIntBE(-0x123456, 0, 3); - assert.deepEqual(buf.toJSON().data, [0xed, 0xcb, 0xaa]); + assert.deepStrictEqual(buf.toJSON().data, [0xed, 0xcb, 0xaa]); assert.equal(buf.readIntBE(0, 3), -0x123456); buf = Buffer.allocUnsafe(3); buf.writeIntLE(-0x123400, 0, 3); - assert.deepEqual(buf.toJSON().data, [0x00, 0xcc, 0xed]); + assert.deepStrictEqual(buf.toJSON().data, [0x00, 0xcc, 0xed]); assert.equal(buf.readIntLE(0, 3), -0x123400); buf = Buffer.allocUnsafe(3); buf.writeIntBE(-0x123400, 0, 3); - assert.deepEqual(buf.toJSON().data, [0xed, 0xcc, 0x00]); + assert.deepStrictEqual(buf.toJSON().data, [0xed, 0xcc, 0x00]); assert.equal(buf.readIntBE(0, 3), -0x123400); buf = Buffer.allocUnsafe(3); buf.writeIntLE(-0x120000, 0, 3); - assert.deepEqual(buf.toJSON().data, [0x00, 0x00, 0xee]); + assert.deepStrictEqual(buf.toJSON().data, [0x00, 0x00, 0xee]); assert.equal(buf.readIntLE(0, 3), -0x120000); buf = Buffer.allocUnsafe(3); buf.writeIntBE(-0x120000, 0, 3); - assert.deepEqual(buf.toJSON().data, [0xee, 0x00, 0x00]); + assert.deepStrictEqual(buf.toJSON().data, [0xee, 0x00, 0x00]); assert.equal(buf.readIntBE(0, 3), -0x120000); buf = Buffer.allocUnsafe(5); buf.writeUIntLE(0x1234567890, 0, 5); - assert.deepEqual(buf.toJSON().data, [0x90, 0x78, 0x56, 0x34, 0x12]); + assert.deepStrictEqual(buf.toJSON().data, [0x90, 0x78, 0x56, 0x34, 0x12]); assert.equal(buf.readUIntLE(0, 5), 0x1234567890); buf = Buffer.allocUnsafe(5); buf.writeUIntBE(0x1234567890, 0, 5); - assert.deepEqual(buf.toJSON().data, [0x12, 0x34, 0x56, 0x78, 0x90]); + assert.deepStrictEqual(buf.toJSON().data, [0x12, 0x34, 0x56, 0x78, 0x90]); assert.equal(buf.readUIntBE(0, 5), 0x1234567890); buf = Buffer.allocUnsafe(5); buf.writeIntLE(0x1234567890, 0, 5); - assert.deepEqual(buf.toJSON().data, [0x90, 0x78, 0x56, 0x34, 0x12]); + assert.deepStrictEqual(buf.toJSON().data, [0x90, 0x78, 0x56, 0x34, 0x12]); assert.equal(buf.readIntLE(0, 5), 0x1234567890); buf = Buffer.allocUnsafe(5); buf.writeIntBE(0x1234567890, 0, 5); - assert.deepEqual(buf.toJSON().data, [0x12, 0x34, 0x56, 0x78, 0x90]); + assert.deepStrictEqual(buf.toJSON().data, [0x12, 0x34, 0x56, 0x78, 0x90]); assert.equal(buf.readIntBE(0, 5), 0x1234567890); buf = Buffer.allocUnsafe(5); buf.writeIntLE(-0x1234567890, 0, 5); - assert.deepEqual(buf.toJSON().data, [0x70, 0x87, 0xa9, 0xcb, 0xed]); + assert.deepStrictEqual(buf.toJSON().data, [0x70, 0x87, 0xa9, 0xcb, 0xed]); assert.equal(buf.readIntLE(0, 5), -0x1234567890); buf = Buffer.allocUnsafe(5); buf.writeIntBE(-0x1234567890, 0, 5); - assert.deepEqual(buf.toJSON().data, [0xed, 0xcb, 0xa9, 0x87, 0x70]); + assert.deepStrictEqual(buf.toJSON().data, [0xed, 0xcb, 0xa9, 0x87, 0x70]); assert.equal(buf.readIntBE(0, 5), -0x1234567890); buf = Buffer.allocUnsafe(5); buf.writeIntLE(-0x0012000000, 0, 5); - assert.deepEqual(buf.toJSON().data, [0x00, 0x00, 0x00, 0xee, 0xff]); + assert.deepStrictEqual(buf.toJSON().data, [0x00, 0x00, 0x00, 0xee, 0xff]); assert.equal(buf.readIntLE(0, 5), -0x0012000000); buf = Buffer.allocUnsafe(5); buf.writeIntBE(-0x0012000000, 0, 5); - assert.deepEqual(buf.toJSON().data, [0xff, 0xee, 0x00, 0x00, 0x00]); + assert.deepStrictEqual(buf.toJSON().data, [0xff, 0xee, 0x00, 0x00, 0x00]); assert.equal(buf.readIntBE(0, 5), -0x0012000000); })(); @@ -1294,7 +1308,7 @@ assert.throws(function() { } var utf16Buf = Buffer.from('0123456789', 'utf16le'); - // assert.deepEqual(utf16Buf.slice(0, 6), Buffer.from('012', 'utf16le')); + // assert.deepStrictEqual(utf16Buf.slice(0, 6), Buffer.from('012', 'utf16le')); assert.equal(buf.slice('0', '1'), '0'); assert.equal(buf.slice('-5', '10'), '56789'); diff --git a/test/node/test-buffer-fill.js b/test/node/test-buffer-fill.js index b65cd99..8714499 100644 --- a/test/node/test-buffer-fill.js +++ b/test/node/test-buffer-fill.js @@ -142,18 +142,25 @@ testBufs('Yci0Ysi1Y8i2', 12, 1, 'ucs2'); // Buffer +function deepStrictEqualValues(buf, arr) { + for (var [index, value] of buf.entries()) { + assert.deepStrictEqual(value, arr[index]); + } +} + + var buf2Fill = Buffer.allocUnsafe(1).fill(2); -assert.deepEqual(genBuffer(4, [buf2Fill]), [2, 2, 2, 2]); -assert.deepEqual(genBuffer(4, [buf2Fill, 1]), [0, 2, 2, 2]); -assert.deepEqual(genBuffer(4, [buf2Fill, 1, 3]), [0, 2, 2, 0]); -assert.deepEqual(genBuffer(4, [buf2Fill, 1, 1]), [0, 0, 0, 0]); -assert.deepEqual(genBuffer(4, [buf2Fill, 1, -1]), [0, 0, 0, 0]); +deepStrictEqualValues(genBuffer(4, [buf2Fill]), [2, 2, 2, 2]); +deepStrictEqualValues(genBuffer(4, [buf2Fill, 1]), [0, 2, 2, 2]); +deepStrictEqualValues(genBuffer(4, [buf2Fill, 1, 3]), [0, 2, 2, 0]); +deepStrictEqualValues(genBuffer(4, [buf2Fill, 1, 1]), [0, 0, 0, 0]); +deepStrictEqualValues(genBuffer(4, [buf2Fill, 1, -1]), [0, 0, 0, 0]); var hexBufFill = Buffer.allocUnsafe(2).fill(0).fill('0102', 'hex'); -assert.deepEqual(genBuffer(4, [hexBufFill]), [1, 2, 1, 2]); -assert.deepEqual(genBuffer(4, [hexBufFill, 1]), [0, 1, 2, 1]); -assert.deepEqual(genBuffer(4, [hexBufFill, 1, 3]), [0, 1, 2, 0]); -assert.deepEqual(genBuffer(4, [hexBufFill, 1, 1]), [0, 0, 0, 0]); -assert.deepEqual(genBuffer(4, [hexBufFill, 1, -1]), [0, 0, 0, 0]); +deepStrictEqualValues(genBuffer(4, [hexBufFill]), [1, 2, 1, 2]); +deepStrictEqualValues(genBuffer(4, [hexBufFill, 1]), [0, 1, 2, 1]); +deepStrictEqualValues(genBuffer(4, [hexBufFill, 1, 3]), [0, 1, 2, 0]); +deepStrictEqualValues(genBuffer(4, [hexBufFill, 1, 1]), [0, 0, 0, 0]); +deepStrictEqualValues(genBuffer(4, [hexBufFill, 1, -1]), [0, 0, 0, 0]); // Check exceptions diff --git a/test/node/test-buffer-iterator.js b/test/node/test-buffer-iterator.js index 33f406d..4b5d51f 100644 --- a/test/node/test-buffer-iterator.js +++ b/test/node/test-buffer-iterator.js @@ -15,7 +15,7 @@ arr = []; for (b of buffer) arr.push(b); -assert.deepEqual(arr, [1, 2, 3, 4, 5]); +assert.deepStrictEqual(arr, [1, 2, 3, 4, 5]); // buffer iterators should be iterable @@ -25,7 +25,7 @@ arr = []; for (b of buffer[Symbol.iterator]()) arr.push(b); -assert.deepEqual(arr, [1, 2, 3, 4, 5]); +assert.deepStrictEqual(arr, [1, 2, 3, 4, 5]); // buffer#values() should return iterator for values @@ -35,7 +35,7 @@ arr = []; for (b of buffer.values()) arr.push(b); -assert.deepEqual(arr, [1, 2, 3, 4, 5]); +assert.deepStrictEqual(arr, [1, 2, 3, 4, 5]); // buffer#keys() should return iterator for keys @@ -45,7 +45,7 @@ arr = []; for (b of buffer.keys()) arr.push(b); -assert.deepEqual(arr, [0, 1, 2, 3, 4]); +assert.deepStrictEqual(arr, [0, 1, 2, 3, 4]); // buffer#entries() should return iterator for entries @@ -55,7 +55,7 @@ arr = []; for (b of buffer.entries()) arr.push(b); -assert.deepEqual(arr, [ +assert.deepStrictEqual(arr, [ [0, 1], [1, 2], [2, 3], diff --git a/test/node/test-buffer-slow.js b/test/node/test-buffer-slow.js index 6d89e5e..c66742d 100644 --- a/test/node/test-buffer-slow.js +++ b/test/node/test-buffer-slow.js @@ -15,7 +15,9 @@ var sb = SlowBuffer(4); assert(sb instanceof Buffer); assert.strictEqual(sb.length, 4); sb.fill(1); -assert.deepEqual(sb, ones); +for (var [key, value] of sb.entries()) { + assert.deepStrictEqual(value, ones[key]); +} // underlying ArrayBuffer should have the same length assert.strictEqual(sb.buffer.byteLength, 4); @@ -25,7 +27,9 @@ sb = SlowBuffer(4); assert(sb instanceof Buffer); assert.strictEqual(sb.length, 4); sb.fill(1); -assert.deepEqual(sb, ones); +for (var [key, value] of sb.entries()) { + assert.deepStrictEqual(value, ones[key]); +} // should work with edge cases assert.strictEqual(SlowBuffer(0).length, 0); diff --git a/test/node/test-buffer.js b/test/node/test-buffer.js index e68b604..0534723 100644 --- a/test/node/test-buffer.js +++ b/test/node/test-buffer.js @@ -35,7 +35,9 @@ assert.strictEqual(0, d.length); var ui32 = new Uint32Array(4).fill(42); var e = Buffer(ui32); -assert.deepEqual(ui32, e); +for (var [key, value] of e.entries()) { + assert.deepStrictEqual(value, ui32[key]); +} // First check Buffer#fill() works as expected. @@ -466,32 +468,33 @@ for (var i = 0; i < Buffer.byteLength(utf8String); i++) { assert.equal(d[0], 23); assert.equal(d[1], 42); assert.equal(d[2], 255); - assert.deepEqual(d, new Buffer(d)); + assert.deepStrictEqual(d, new Buffer(d)); } { var e = new Buffer('über'); // console.error('uber: \'%s\'', e.toString()); - assert.deepEqual(e, new Buffer([195, 188, 98, 101, 114])); + assert.deepStrictEqual(e, new Buffer([195, 188, 98, 101, 114])); } { var f = new Buffer('über', 'ascii'); // console.error('f.length: %d (should be 4)', f.length); - assert.deepEqual(f, new Buffer([252, 98, 101, 114])); + assert.deepStrictEqual(f, new Buffer([252, 98, 101, 114])); } ['ucs2', 'ucs-2', 'utf16le', 'utf-16le'].forEach(function(encoding) { { var f = new Buffer('über', encoding); // console.error('f.length: %d (should be 8)', f.length); - assert.deepEqual(f, new Buffer([252, 0, 98, 0, 101, 0, 114, 0])); + assert.deepStrictEqual(f, new Buffer([252, 0, 98, 0, 101, 0, 114, 0])); } { var f = new Buffer('привет', encoding); // console.error('f.length: %d (should be 12)', f.length); - assert.deepEqual(f, new Buffer([63, 4, 64, 4, 56, 4, 50, 4, 53, 4, 66, 4])); + var expected = new Buffer([63, 4, 64, 4, 56, 4, 50, 4, 53, 4, 66, 4]); + assert.deepStrictEqual(f, expected); assert.equal(f.toString(encoding), 'привет'); } @@ -501,23 +504,23 @@ for (var i = 0; i < Buffer.byteLength(utf8String); i++) { var size = f.write('あいうえお', encoding); // console.error('bytes written to buffer: %d (should be 4)', size); assert.equal(size, 4); - assert.deepEqual(f, new Buffer([0x42, 0x30, 0x44, 0x30, 0x00])); + assert.deepStrictEqual(f, new Buffer([0x42, 0x30, 0x44, 0x30, 0x00])); } }); { var f = new Buffer('\uD83D\uDC4D', 'utf-16le'); // THUMBS UP SIGN (U+1F44D) assert.equal(f.length, 4); - assert.deepEqual(f, new Buffer('3DD84DDC', 'hex')); + assert.deepStrictEqual(f, new Buffer('3DD84DDC', 'hex')); } var arrayIsh = {0: 0, 1: 1, 2: 2, 3: 3, length: 4}; var g = new Buffer(arrayIsh); -assert.deepEqual(g, new Buffer([0, 1, 2, 3])); +assert.deepStrictEqual(g, new Buffer([0, 1, 2, 3])); var strArrayIsh = {0: '0', 1: '1', 2: '2', 3: '3', length: 4}; g = new Buffer(strArrayIsh); -assert.deepEqual(g, new Buffer([0, 1, 2, 3])); +assert.deepStrictEqual(g, new Buffer([0, 1, 2, 3])); // @@ -528,8 +531,8 @@ assert.equal('TWFu', (new Buffer('Man')).toString('base64')); { // test that regular and URL-safe base64 both work var expected = [0xff, 0xff, 0xbe, 0xff, 0xef, 0xbf, 0xfb, 0xef, 0xff]; - assert.deepEqual(Buffer('//++/++/++//', 'base64'), Buffer(expected)); - assert.deepEqual(Buffer('__--_--_--__', 'base64'), Buffer(expected)); + assert.deepStrictEqual(Buffer('//++/++/++//', 'base64'), Buffer(expected)); + assert.deepStrictEqual(Buffer('__--_--_--__', 'base64'), Buffer(expected)); } { @@ -642,18 +645,30 @@ assert.equal(new Buffer('KioqKioqKioqKioqKioqKioqKio', 'base64').toString(), '********************'); // handle padding graciously, multiple-of-4 or not -assert.equal(new Buffer('72INjkR5fchcxk9+VgdGPFJDxUBFR5/rMFsghgxADiw==', - 'base64').length, 32); -assert.equal(new Buffer('72INjkR5fchcxk9+VgdGPFJDxUBFR5/rMFsghgxADiw=', - 'base64').length, 32); -assert.equal(new Buffer('72INjkR5fchcxk9+VgdGPFJDxUBFR5/rMFsghgxADiw', - 'base64').length, 32); -assert.equal(new Buffer('w69jACy6BgZmaFvv96HG6MYksWytuZu3T1FvGnulPg==', - 'base64').length, 31); -assert.equal(new Buffer('w69jACy6BgZmaFvv96HG6MYksWytuZu3T1FvGnulPg=', - 'base64').length, 31); -assert.equal(new Buffer('w69jACy6BgZmaFvv96HG6MYksWytuZu3T1FvGnulPg', - 'base64').length, 31); +assert.equal( + new Buffer('72INjkR5fchcxk9+VgdGPFJDxUBFR5/rMFsghgxADiw==', 'base64').length, + 32 +); +assert.equal( + new Buffer('72INjkR5fchcxk9+VgdGPFJDxUBFR5/rMFsghgxADiw=', 'base64').length, + 32 +); +assert.equal( + new Buffer('72INjkR5fchcxk9+VgdGPFJDxUBFR5/rMFsghgxADiw', 'base64').length, + 32 +); +assert.equal( + new Buffer('w69jACy6BgZmaFvv96HG6MYksWytuZu3T1FvGnulPg==', 'base64').length, + 31 +); +assert.equal( + new Buffer('w69jACy6BgZmaFvv96HG6MYksWytuZu3T1FvGnulPg=', 'base64').length, + 31 +); +assert.equal( + new Buffer('w69jACy6BgZmaFvv96HG6MYksWytuZu3T1FvGnulPg', 'base64').length, + 31 +); // This string encodes single '.' character in UTF-16 var dot = new Buffer('//4uAA==', 'base64'); @@ -1015,7 +1030,7 @@ Buffer(Buffer(0), 0, 0); assert.equal(string, '{"type":"Buffer","data":[116,101,115,116]}'); - assert.deepEqual(buffer, JSON.parse(string, function(key, value) { + assert.deepStrictEqual(buffer, JSON.parse(string, function(key, value) { return value && value.type === 'Buffer' ? new Buffer(value.data) : value; @@ -1171,92 +1186,92 @@ assert.throws(function() { (function() { var buf = Buffer(3); buf.writeUIntLE(0x123456, 0, 3); - assert.deepEqual(buf.toJSON().data, [0x56, 0x34, 0x12]); + assert.deepStrictEqual(buf.toJSON().data, [0x56, 0x34, 0x12]); assert.equal(buf.readUIntLE(0, 3), 0x123456); buf = Buffer(3); buf.writeUIntBE(0x123456, 0, 3); - assert.deepEqual(buf.toJSON().data, [0x12, 0x34, 0x56]); + assert.deepStrictEqual(buf.toJSON().data, [0x12, 0x34, 0x56]); assert.equal(buf.readUIntBE(0, 3), 0x123456); buf = Buffer(3); buf.writeIntLE(0x123456, 0, 3); - assert.deepEqual(buf.toJSON().data, [0x56, 0x34, 0x12]); + assert.deepStrictEqual(buf.toJSON().data, [0x56, 0x34, 0x12]); assert.equal(buf.readIntLE(0, 3), 0x123456); buf = Buffer(3); buf.writeIntBE(0x123456, 0, 3); - assert.deepEqual(buf.toJSON().data, [0x12, 0x34, 0x56]); + assert.deepStrictEqual(buf.toJSON().data, [0x12, 0x34, 0x56]); assert.equal(buf.readIntBE(0, 3), 0x123456); buf = Buffer(3); buf.writeIntLE(-0x123456, 0, 3); - assert.deepEqual(buf.toJSON().data, [0xaa, 0xcb, 0xed]); + assert.deepStrictEqual(buf.toJSON().data, [0xaa, 0xcb, 0xed]); assert.equal(buf.readIntLE(0, 3), -0x123456); buf = Buffer(3); buf.writeIntBE(-0x123456, 0, 3); - assert.deepEqual(buf.toJSON().data, [0xed, 0xcb, 0xaa]); + assert.deepStrictEqual(buf.toJSON().data, [0xed, 0xcb, 0xaa]); assert.equal(buf.readIntBE(0, 3), -0x123456); buf = Buffer(3); buf.writeIntLE(-0x123400, 0, 3); - assert.deepEqual(buf.toJSON().data, [0x00, 0xcc, 0xed]); + assert.deepStrictEqual(buf.toJSON().data, [0x00, 0xcc, 0xed]); assert.equal(buf.readIntLE(0, 3), -0x123400); buf = Buffer(3); buf.writeIntBE(-0x123400, 0, 3); - assert.deepEqual(buf.toJSON().data, [0xed, 0xcc, 0x00]); + assert.deepStrictEqual(buf.toJSON().data, [0xed, 0xcc, 0x00]); assert.equal(buf.readIntBE(0, 3), -0x123400); buf = Buffer(3); buf.writeIntLE(-0x120000, 0, 3); - assert.deepEqual(buf.toJSON().data, [0x00, 0x00, 0xee]); + assert.deepStrictEqual(buf.toJSON().data, [0x00, 0x00, 0xee]); assert.equal(buf.readIntLE(0, 3), -0x120000); buf = Buffer(3); buf.writeIntBE(-0x120000, 0, 3); - assert.deepEqual(buf.toJSON().data, [0xee, 0x00, 0x00]); + assert.deepStrictEqual(buf.toJSON().data, [0xee, 0x00, 0x00]); assert.equal(buf.readIntBE(0, 3), -0x120000); buf = Buffer(5); buf.writeUIntLE(0x1234567890, 0, 5); - assert.deepEqual(buf.toJSON().data, [0x90, 0x78, 0x56, 0x34, 0x12]); + assert.deepStrictEqual(buf.toJSON().data, [0x90, 0x78, 0x56, 0x34, 0x12]); assert.equal(buf.readUIntLE(0, 5), 0x1234567890); buf = Buffer(5); buf.writeUIntBE(0x1234567890, 0, 5); - assert.deepEqual(buf.toJSON().data, [0x12, 0x34, 0x56, 0x78, 0x90]); + assert.deepStrictEqual(buf.toJSON().data, [0x12, 0x34, 0x56, 0x78, 0x90]); assert.equal(buf.readUIntBE(0, 5), 0x1234567890); buf = Buffer(5); buf.writeIntLE(0x1234567890, 0, 5); - assert.deepEqual(buf.toJSON().data, [0x90, 0x78, 0x56, 0x34, 0x12]); + assert.deepStrictEqual(buf.toJSON().data, [0x90, 0x78, 0x56, 0x34, 0x12]); assert.equal(buf.readIntLE(0, 5), 0x1234567890); buf = Buffer(5); buf.writeIntBE(0x1234567890, 0, 5); - assert.deepEqual(buf.toJSON().data, [0x12, 0x34, 0x56, 0x78, 0x90]); + assert.deepStrictEqual(buf.toJSON().data, [0x12, 0x34, 0x56, 0x78, 0x90]); assert.equal(buf.readIntBE(0, 5), 0x1234567890); buf = Buffer(5); buf.writeIntLE(-0x1234567890, 0, 5); - assert.deepEqual(buf.toJSON().data, [0x70, 0x87, 0xa9, 0xcb, 0xed]); + assert.deepStrictEqual(buf.toJSON().data, [0x70, 0x87, 0xa9, 0xcb, 0xed]); assert.equal(buf.readIntLE(0, 5), -0x1234567890); buf = Buffer(5); buf.writeIntBE(-0x1234567890, 0, 5); - assert.deepEqual(buf.toJSON().data, [0xed, 0xcb, 0xa9, 0x87, 0x70]); + assert.deepStrictEqual(buf.toJSON().data, [0xed, 0xcb, 0xa9, 0x87, 0x70]); assert.equal(buf.readIntBE(0, 5), -0x1234567890); buf = Buffer(5); buf.writeIntLE(-0x0012000000, 0, 5); - assert.deepEqual(buf.toJSON().data, [0x00, 0x00, 0x00, 0xee, 0xff]); + assert.deepStrictEqual(buf.toJSON().data, [0x00, 0x00, 0x00, 0xee, 0xff]); assert.equal(buf.readIntLE(0, 5), -0x0012000000); buf = Buffer(5); buf.writeIntBE(-0x0012000000, 0, 5); - assert.deepEqual(buf.toJSON().data, [0xff, 0xee, 0x00, 0x00, 0x00]); + assert.deepStrictEqual(buf.toJSON().data, [0xff, 0xee, 0x00, 0x00, 0x00]); assert.equal(buf.readIntBE(0, 5), -0x0012000000); })(); @@ -1296,7 +1311,7 @@ assert.throws(function() { } var utf16Buf = new Buffer('0123456789', 'utf16le'); - // assert.deepEqual(utf16Buf.slice(0, 6), Buffer('012', 'utf16le')); + // assert.deepStrictEqual(utf16Buf.slice(0, 6), Buffer('012', 'utf16le')); assert.equal(buf.slice('0', '1'), '0'); assert.equal(buf.slice('-5', '10'), '56789');