Permalink
Browse files

add test for random integers

  • Loading branch information...
1 parent 404110a commit aee34b9680243d9e69d2032d785d526f1114004c @pvorb committed Nov 25, 2012
Showing with 10 additions and 0 deletions.
  1. +10 −0 test.js
View
10 test.js
@@ -5,4 +5,14 @@ describe('MD5', function () {
it('should return the expected MD5 hash for "message"', function () {
assert.equal('78e731027d8fd50ed642340b7c9a63b3', md5('message'));
});
+
+ it('should not return the same hash for random numbers twice', function () {
+ var msg1 = Math.floor((Math.random() * 100000) + 1) + (new Date).getTime();
+ var msg2 = Math.floor((Math.random() * 100000) + 1) + (new Date).getTime();
+
+ if (msg1 !== msg2)
+ assert.notEqual(md5(msg1), md5(msg2));
+ else
+ assert.equal(md5(msg1), md5(msg1));
+ });
});

0 comments on commit aee34b9

Please sign in to comment.