From 123131af4884878e77bc0bdb573dd16253455ce3 Mon Sep 17 00:00:00 2001 From: Feross Aboukhadijeh Date: Fri, 27 Dec 2013 21:38:02 -0800 Subject: [PATCH] Make toArrayBuffer() test more robust --- test/basic.js | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/test/basic.js b/test/basic.js index 8af68cc..75a190e 100644 --- a/test/basic.js +++ b/test/basic.js @@ -19,17 +19,14 @@ test('new buffer from string', function (t) { t.end() }) -function arraybufferToString (arraybuffer) { - return String.fromCharCode.apply(null, new Uint16Array(arraybuffer)) -} - test('buffer toArrayBuffer()', function (t) { var data = [1, 2, 3, 4, 5, 6, 7, 8] if (typeof (new B(data)).toArrayBuffer === 'function') { - t.equal( - arraybufferToString(new B(data).toArrayBuffer()), - arraybufferToString(new Uint8Array(data).buffer) - ) + var result = new B(data).toArrayBuffer() + var expected = new Uint8Array(data).buffer + for (var i = 0; i < expected.length; i++) { + t.equal(result[i], expected[i]) + } } else { t.pass('No toArrayBuffer() method provided in old browsers') } -- 2.34.1