react / react-0.13.3 / examples / basic-commonjs / node_modules / browserify / node_modules / buffer / test / compare.js
80724 viewsvar B = require('../').Buffer1var test = require('tape')2if (process.env.OBJECT_IMPL) B.TYPED_ARRAY_SUPPORT = false345test('buffer.compare', function (t) {6var b = new B(1).fill('a')7var c = new B(1).fill('c')8var d = new B(2).fill('aa')910t.equal(b.compare(c), -1)11t.equal(c.compare(d), 1)12t.equal(d.compare(b), 1)13t.equal(b.compare(d), -1)1415// static method16t.equal(B.compare(b, c), -1)17t.equal(B.compare(c, d), 1)18t.equal(B.compare(d, b), 1)19t.equal(B.compare(b, d), -1)20t.end()21})2223test('buffer.compare argument validation', function (t) {24t.throws(function () {25var b = new B(1)26B.compare(b, 'abc')27})2829t.throws(function () {30var b = new B(1)31B.compare('abc', b)32})3334t.throws(function () {35var b = new B(1)36b.compare('abc')37})38t.end()39})4041test('buffer.equals', function (t) {42var b = new B(5).fill('abcdf')43var c = new B(5).fill('abcdf')44var d = new B(5).fill('abcde')45var e = new B(6).fill('abcdef')4647t.ok(b.equals(c))48t.ok(!c.equals(d))49t.ok(!d.equals(e))50t.end()51})5253test('buffer.equals argument validation', function (t) {54t.throws(function () {55var b = new B(1)56b.equals('abc')57})58t.end()59})606162