Skip to content

Commit

Permalink
Added basic tests for hasher
Browse files Browse the repository at this point in the history
Signed-off-by: dark0dave <dark0dave@mykolab.com>
  • Loading branch information
dark0dave committed Feb 28, 2018
1 parent b24db4e commit 3236f36
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions test/hasher.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
const { murmurhash3_32_gc, murmurhash3_128_raw_gc } = require('../src/hasher.js');

describe('helpers', () => {
describe('murmurhash3_32_gc', () => {
it('should return a hash', () => {
expect(murmurhash3_32_gc('Hello, World!', 100)).toBe(1305297264);
});

it('different seeds should return different hashes', () => {
expect(murmurhash3_32_gc('Hello, World!', 1) !== murmurhash3_32_gc('Hello, World!', 10));
});
});

describe('murmurhash3_128_raw_gc', () => {
it('should return a hash', () => {
expect(murmurhash3_128_raw_gc('Hello, World!', 100)).toEqual([1144378930, 1125695904, 3198765882, 690283472]);
});

it('can deal with huge strings', () => {
expect(murmurhash3_128_raw_gc(Array(65537).join('a'), 0)).toEqual([2724439033, 136575893, 411989173, 1597363643]);
});

it('different seeds should return different hashes', () => {
expect(murmurhash3_128_raw_gc('Hello, World!', 1) !== murmurhash3_128_raw_gc('Hello, World!', 10));
});
});
});

0 comments on commit 3236f36

Please sign in to comment.