Comparing version 1.1.0 to 1.2.0
{ | ||
"name": "metrohash", | ||
"version": "1.1.0", | ||
"version": "1.2.0", | ||
"description": "Node.js bindings for MetroHash hashing library", | ||
@@ -5,0 +5,0 @@ "scripts" : { |
@@ -35,3 +35,3 @@ # node-metrohash | ||
// Instantiate using seed 123. | ||
// Instantiate using seed 123 (`new` is optional). | ||
var hash = new MetroHash64(123); | ||
@@ -38,0 +38,0 @@ |
56
test.js
@@ -17,8 +17,40 @@ var MetroHash64 = require('./index').MetroHash64; | ||
describe('MetroHash', function() { | ||
describe('Instantiation and method calling', function() { | ||
it('new MetroHash64() should work', function() { | ||
expect(function() { new MetroHash64(); }).to.not.throw(); | ||
}); | ||
it('MetroHash64() should work', function() { | ||
expect(function() { MetroHash64(); }).to.not.throw(); | ||
}); | ||
it('new MetroHash128() should work', function() { | ||
expect(function() { new MetroHash128(); }).to.not.throw(); | ||
}); | ||
it('MetroHash128() should work', function() { | ||
expect(function() { MetroHash128(); }).to.not.throw(); | ||
}); | ||
it('MetroHash64() should allow chaining', function() { | ||
expect(function() { | ||
new MetroHash64().update(TESTVECTOR_B).digest().toString('hex'); | ||
}).to.not.throw(); | ||
}); | ||
it('MetroHash128() should allow chaining', function() { | ||
expect(function() { | ||
new MetroHash128().update(TESTVECTOR_B).digest().toString('hex'); | ||
}).to.not.throw(); | ||
}); | ||
}); | ||
describe('Test vectors', function() { | ||
TESTS.forEach(function(test) { | ||
var suffix = test.seed !== undefined ? ', ' + test.seed + ')' : ')'; | ||
it(test.cls.name + '(String' + suffix, function() { | ||
it('new ' + test.cls.name + '(String' + suffix, function() { | ||
var instance = new test.cls(test.seed); | ||
@@ -29,3 +61,9 @@ instance.update(TESTVECTOR_S); | ||
it(test.cls.name + '(Buffer' + suffix, function() { | ||
it(test.cls.name + '(String' + suffix, function() { | ||
var instance = test.cls(test.seed); | ||
instance.update(TESTVECTOR_S); | ||
expect(instance.digest().toString('hex').toUpperCase()).to.equal(test.expected); | ||
}); | ||
it('new ' + test.cls.name + '(Buffer' + suffix, function() { | ||
var instance = new test.cls(test.seed); | ||
@@ -36,10 +74,10 @@ instance.update(TESTVECTOR_B); | ||
}); | ||
it(test.cls.name + '(Buffer' + suffix, function() { | ||
var instance = test.cls(test.seed); | ||
instance.update(TESTVECTOR_B); | ||
expect(instance.digest().toString('hex').toUpperCase()).to.equal(test.expected); | ||
}); | ||
it('should allow chaining', function() { | ||
expect(function() { | ||
new MetroHash64().update(TESTVECTOR_B).digest().toString('hex'); | ||
}).to.not.throw(); | ||
}); | ||
}); | ||
}) |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
62013
63