-
Notifications
You must be signed in to change notification settings - Fork 10k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add basic unit-tests for murmurhash3.js
- Loading branch information
1 parent
451956c
commit 15b2c05
Showing
3 changed files
with
61 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
/* globals jasmine, expect, it, describe, MurmurHash3_64 */ | ||
'use strict'; | ||
|
||
describe('MurmurHash3_64', function() { | ||
|
||
it('instantiates without seed ', function() { | ||
var hash = new MurmurHash3_64(); | ||
expect(hash).toEqual(jasmine.any(MurmurHash3_64)); | ||
}); | ||
it('instantiates with seed ', function() { | ||
var hash = new MurmurHash3_64(1); | ||
expect(hash).toEqual(jasmine.any(MurmurHash3_64)); | ||
}); | ||
|
||
var hexDigestExpected = 'f61cfdbfdae0f65e'; | ||
var sourceText = 'test'; | ||
var sourceCharCodes = [116,101,115,116]; // 't','e','s','t' | ||
it('generates expected from string', function() { | ||
var hash = new MurmurHash3_64(); | ||
hash.update(sourceText); | ||
expect(hash.hexdigest()).toEqual(hexDigestExpected); | ||
}); | ||
it('generates expected from Uint8Array', function() { | ||
var hash = new MurmurHash3_64(); | ||
hash.update(new Uint8Array(sourceCharCodes)); | ||
expect(hash.hexdigest()).toEqual(hexDigestExpected); | ||
}); | ||
it('generates expected from Uint32Array', function() { | ||
var hash = new MurmurHash3_64(); | ||
hash.update(new Uint32Array(sourceCharCodes)); | ||
expect(hash.hexdigest()).toEqual(hexDigestExpected); | ||
}); | ||
|
||
it('hexdigest changes after update without seed', function() { | ||
var hash = new MurmurHash3_64(); | ||
var hexdigest1, hexdigest2; | ||
hash.update('test'); | ||
hexdigest1 = hash.hexdigest(); | ||
hash.update('test'); | ||
hexdigest2 = hash.hexdigest(); | ||
expect(hexdigest1).not.toEqual(hexdigest2); | ||
}); | ||
it('hexdigest changes after update with seed', function() { | ||
var hash = new MurmurHash3_64(1); | ||
var hexdigest1, hexdigest2; | ||
hash.update('test'); | ||
hexdigest1 = hash.hexdigest(); | ||
hash.update('test'); | ||
hexdigest2 = hash.hexdigest(); | ||
expect(hexdigest1).not.toEqual(hexdigest2); | ||
}); | ||
|
||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters