-
Notifications
You must be signed in to change notification settings - Fork 10k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add basic unit-tests for murmurhash3.js #7857
add basic unit-tests for murmurhash3.js #7857
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work! This commit looks good to me with the comments addressed. Don't forget to squash multiple commits into one commit after addressing the comments (see https://github.com/mozilla/pdf.js/wiki/Squashing-Commits for how to do this easily if you're not familiar with the concept).
@@ -0,0 +1,53 @@ | |||
/* globals jasmine, expect, it, describe, MurmurHash3_64 */ | |||
'use strict'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: add a newline before this line.
'use strict'; | ||
|
||
describe('MurmurHash3_64', function() { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: remove this newline.
hexdigest2 = hash.hexdigest(); | ||
expect(hexdigest1).not.toEqual(hexdigest2); | ||
}); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: remove this newline.
describe('MurmurHash3_64', function() { | ||
|
||
it('instantiates without seed ', function() { | ||
var hash = new MurmurHash3_64(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indent this line with two spaces instead of four, i.e., remove two spaces. We always indent with two spaces. This also applies to the other occurrences in this file.
|
||
describe('MurmurHash3_64', function() { | ||
|
||
it('instantiates without seed ', function() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: remove the space at the end of the string. This also applies to the unit test below.
|
||
var hexDigestExpected = 'f61cfdbfdae0f65e'; | ||
var sourceText = 'test'; | ||
var sourceCharCodes = [116,101,115,116]; // 't','e','s','t' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: add spaces after each comma.
var hexDigestExpected = 'f61cfdbfdae0f65e'; | ||
var sourceText = 'test'; | ||
var sourceCharCodes = [116,101,115,116]; // 't','e','s','t' | ||
it('generates expected from string', function() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would change this to correctly generates a hash from a string
(and Uint8Array
/Uint32Array
below) as it's a bit more descriptive in the logs when running the unit tests.
expect(hash.hexdigest()).toEqual(hexDigestExpected); | ||
}); | ||
|
||
it('hexdigest changes after update without seed', function() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would change this to changes the hash after update without seed
(and similar for the test below) to make it more readable in combination with the it
function.
it('hexdigest changes after update without seed', function() { | ||
var hash = new MurmurHash3_64(); | ||
var hexdigest1, hexdigest2; | ||
hash.update('test'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since you defined var sourceText = 'test';
above, any reason not to just use hash.update(sourceText);
here instead?
(This question applies in a couple of places below as well.)
15b2c05
to
54fab60
Compare
@timvandermeij and @Snuffleupagus thanks for your comments. |
/botio unittest |
From: Bot.io (Windows)ReceivedCommand cmd_unittest from @timvandermeij received. Current queue size: 0 Live output at: http://107.22.172.223:8877/422569bf689d9d5/output.txt |
From: Bot.io (Linux)ReceivedCommand cmd_unittest from @timvandermeij received. Current queue size: 0 Live output at: http://107.21.233.14:8877/16c5f2515c45bb2/output.txt |
From: Bot.io (Linux)SuccessFull output at http://107.21.233.14:8877/16c5f2515c45bb2/output.txt Total script time: 1.98 mins
|
From: Bot.io (Windows)SuccessFull output at http://107.22.172.223:8877/422569bf689d9d5/output.txt Total script time: 2.71 mins
|
Thank you for the patch! |
add basic unit-tests for murmurhash3.js
It adds some tests for murmurhash3 as suggested on #7261