diff options
Diffstat (limited to 'vespajlib/src/test/java/com/yahoo/collections/MD5TestCase.java')
-rw-r--r-- | vespajlib/src/test/java/com/yahoo/collections/MD5TestCase.java | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/vespajlib/src/test/java/com/yahoo/collections/MD5TestCase.java b/vespajlib/src/test/java/com/yahoo/collections/MD5TestCase.java new file mode 100644 index 00000000000..a107b21abb1 --- /dev/null +++ b/vespajlib/src/test/java/com/yahoo/collections/MD5TestCase.java @@ -0,0 +1,33 @@ +// Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +package com.yahoo.collections; + +/** + * @author <a href="mailto:einarmr@yahoo-inc.com">Einar M R Rosenvinge</a> + */ +public class MD5TestCase extends junit.framework.TestCase { + public void testMD5() { + MD5 md5 = new MD5(); + int a = md5.hash("foobar"); + int b = md5.hash("foobar"); + + assertEquals(a, b); + + int c = md5.hash("foo"); + + assertTrue(a != c); + assertTrue(b != c); + + //rudimentary check; see that all four bytes contain something: + + assertTrue((a & 0xFF000000) != 0); + assertTrue((a & 0x00FF0000) != 0); + assertTrue((a & 0x0000FF00) != 0); + assertTrue((a & 0x000000FF) != 0); + + + assertTrue((c & 0xFF000000) != 0); + assertTrue((c & 0x00FF0000) != 0); + assertTrue((c & 0x0000FF00) != 0); + assertTrue((c & 0x000000FF) != 0); + } +} |