Skip to content

Commit

Permalink
fix tests for very old versions of node
Browse files Browse the repository at this point in the history
  • Loading branch information
thejoshwolfe committed Apr 22, 2017
1 parent dbc9333 commit 6dd3717
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion test/range-test.js
Expand Up @@ -119,7 +119,7 @@ function runTest(cb) {
if (err) throw err;
readStream.pipe(BufferList(function(err, data) {
var prefix = "openReadStream with range(" + start + "," + end + "," + index + "): ";
if (!data.equals(expectedSlice)) {
if (!buffersEqual(data, expectedSlice)) {
throw new Error(prefix + "contents mismatch");
}
console.log(prefix + "pass");
Expand All @@ -143,4 +143,12 @@ function hexToBuffer(hexString) {
return buffer;
}

function buffersEqual(a, b) {
if (a.length !== b.length) return false;
for (var i = 0; i < a.length; i++) {
if (a[i] !== b[i]) return false;
}
return true;
}

if (require.main === module) runTest(function() {});

0 comments on commit 6dd3717

Please sign in to comment.