This is an automated email from the ASF dual-hosted git repository.

aherbert pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-codec.git

commit a1fb8486705ff6cea89b0670036c0574d407c339
Author: aherbert <aherb...@apache.org>
AuthorDate: Thu Nov 21 17:00:42 2019 +0000

    MurmurHashTest2: Use Assert.equals and conditional Assert.fail.
---
 .../commons/codec/digest/MurmurHash2Test.java      | 33 +++++++++++-----------
 1 file changed, 17 insertions(+), 16 deletions(-)

diff --git a/src/test/java/org/apache/commons/codec/digest/MurmurHash2Test.java 
b/src/test/java/org/apache/commons/codec/digest/MurmurHash2Test.java
index a121909..9aee349 100644
--- a/src/test/java/org/apache/commons/codec/digest/MurmurHash2Test.java
+++ b/src/test/java/org/apache/commons/codec/digest/MurmurHash2Test.java
@@ -17,9 +17,7 @@
 
 package org.apache.commons.codec.digest;
 
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
+import org.junit.Assert;
 import org.junit.Test;
 
 public class MurmurHash2Test {
@@ -85,8 +83,8 @@ public class MurmurHash2Test {
         for (int i = 0; i < input.length; i++) {
             final int hash = MurmurHash2.hash32(input[i], input[i].length, 
0x71b4954d);
             if (hash != results32_seed[i]) {
-                fail(String.format("Unexpected hash32 result for example %d: 
0x%08x instead of 0x%08x", i, hash,
-                        results32_seed[i]));
+                Assert.fail(String.format("Unexpected hash32 result for 
example %d: 0x%08x instead of 0x%08x", i, hash,
+                            results32_seed[i]));
             }
         }
     }
@@ -96,8 +94,8 @@ public class MurmurHash2Test {
         for (int i = 0; i < input.length; i++) {
             final int hash = MurmurHash2.hash32(input[i], input[i].length);
             if (hash != results32_standard[i]) {
-                fail(String.format("Unexpected hash32 result for example %d: 
0x%08x instead of 0x%08x", i, hash,
-                        results32_standard[i]));
+                Assert.fail(String.format("Unexpected hash32 result for 
example %d: 0x%08x instead of 0x%08x", i, hash,
+                            results32_standard[i]));
             }
         }
     }
@@ -105,21 +103,23 @@ public class MurmurHash2Test {
     @Test
     public void testHash32String() {
         final int hash = MurmurHash2.hash32(text);
-        assertTrue(hash == 0xb3bf597e);
+        Assert.assertEquals(0xb3bf597e, hash);
     }
 
     @Test
     public void testHash32StringIntInt() {
         final int hash = MurmurHash2.hash32(text, 2, text.length() - 4);
-        assertTrue(hash == 0x4d666d90);
+        Assert.assertEquals(0x4d666d90, hash);
     }
 
     @Test
     public void testHash64ByteArrayIntInt() {
         for (int i = 0; i < input.length; i++) {
             final long hash = MurmurHash2.hash64(input[i], input[i].length, 
0x344d1f5c);
-            assertTrue(String.format("Unexpected hash64 result for example %d: 
0x%016x instead of 0x%016x", i, hash,
-                    results64_seed[i]), hash == results64_seed[i]);
+            if (hash != results64_seed[i]) {
+                Assert.fail(String.format("Unexpected hash64 result for 
example %d: 0x%016x instead of 0x%016x", i, hash,
+                            results64_seed[i]));
+            }
         }
     }
 
@@ -127,21 +127,22 @@ public class MurmurHash2Test {
     public void testHash64ByteArrayInt() {
         for (int i = 0; i < input.length; i++) {
             final long hash = MurmurHash2.hash64(input[i], input[i].length);
-            assertTrue(String.format("Unexpected hash64 result for example %d: 
0x%016x instead of 0x%016x", i, hash,
-                    results64_standard[i]), hash == results64_standard[i]);
+            if (hash != results64_standard[i]) {
+                Assert.fail(String.format("Unexpected hash64 result for 
example %d: 0x%016x instead of 0x%016x", i, hash,
+                    results64_standard[i]));
+            }
         }
     }
 
     @Test
     public void testHash64String() {
         final long hash = MurmurHash2.hash64(text);
-        assertTrue(hash == 0x0920e0c1b7eeb261l);
+        Assert.assertEquals(0x0920e0c1b7eeb261L, hash);
     }
 
     @Test
     public void testHash64StringIntInt() {
         final long hash = MurmurHash2.hash64(text, 2, text.length() - 4);
-        assertTrue(hash == 0xa8b33145194985a2l);
+        Assert.assertEquals(0xa8b33145194985a2L, hash);
     }
-
 }

Reply via email to