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

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


The following commit(s) were added to refs/heads/master by this push:
     new 438b54b  CODEC-285 HexTest
438b54b is described below

commit 438b54b2075652215a75a834ee64ec5b0b29a6f8
Author: John Patrick <142304+nhojpatr...@users.noreply.github.com>
AuthorDate: Sat Feb 19 22:36:16 2022 +0000

    CODEC-285 HexTest
    
    Looking at @Test(expected) and test method body, the last line usually 
throws the expected but test actually fails earlier.
---
 src/test/java/org/apache/commons/codec/binary/HexTest.java | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/src/test/java/org/apache/commons/codec/binary/HexTest.java 
b/src/test/java/org/apache/commons/codec/binary/HexTest.java
index 1fc543f..ff4b04c 100644
--- a/src/test/java/org/apache/commons/codec/binary/HexTest.java
+++ b/src/test/java/org/apache/commons/codec/binary/HexTest.java
@@ -555,20 +555,18 @@ public class HexTest {
         assertArrayEquals("64".toCharArray(), hex);
     }
 
-    @Test(expected=ArrayIndexOutOfBoundsException.class)
+    @Test
     public void testEncodeHexPartialInputUnderbounds() {
         final byte data[] = "hello world".getBytes(StandardCharsets.UTF_8);
 
-        final char[] hex = Hex.encodeHex(data, -2, 10, true);
-        assertArrayEquals("64".toCharArray(), hex);
+        assertThrows(ArrayIndexOutOfBoundsException.class, () -> 
Hex.encodeHex(data, -2, 10, true));
     }
 
-    @Test(expected=ArrayIndexOutOfBoundsException.class)
+    @Test
     public void testEncodeHexPartialInputOverbounds() {
         final byte data[] = "hello world".getBytes(StandardCharsets.UTF_8);
 
-        final char[] hex = Hex.encodeHex(data, 9, 10, true);
-        assertArrayEquals("64".toCharArray(), hex);
+        assertThrows(ArrayIndexOutOfBoundsException.class, () -> 
Hex.encodeHex(data, 9, 10, true));
     }
 
     @Test

Reply via email to