-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathtest.js
More file actions
19 lines (17 loc) · 806 Bytes
/
test.js
File metadata and controls
19 lines (17 loc) · 806 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
require('./');
var A = Buffer('123');
var B = Buffer('0123');
var C = Buffer('xyz');
console.log('Buffer.prototype.compare : ');
console.log('should return 0 when a byte sequences matches and buffers are of equal length');
console.assert(A.compare(A) === 0, 'Failed:' + A.compare(A));
console.log('Passed');
console.log('should return 1 when a byte sequence matches and the left buffer is smaller');
console.assert(A.compare(B) === 1, 'Failed:' + A.compare(B));
console.log('Passed');
console.log('should return 1 when a byte sequence matches and the left buffer is larger');
console.assert(B.compare(A) === -1, 'Failed:' + B.compare(A));
console.log('Passed');
console.log('should return -1 when there is no match');
console.assert(A.compare(C) === -1, 'Failed:' + A.compare(C));
console.log('Passed');