Skip to content

Commit 438b54b

Browse files
nhojpatrickkinow
authored andcommitted
CODEC-285 HexTest
Looking at @test(expected) and test method body, the last line usually throws the expected but test actually fails earlier.
1 parent d25af0e commit 438b54b

1 file changed

Lines changed: 4 additions & 6 deletions

File tree

src/test/java/org/apache/commons/codec/binary/HexTest.java

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -555,20 +555,18 @@ public void testEncodeHexPartialInput() {
555555
assertArrayEquals("64".toCharArray(), hex);
556556
}
557557

558-
@Test(expected=ArrayIndexOutOfBoundsException.class)
558+
@Test
559559
public void testEncodeHexPartialInputUnderbounds() {
560560
final byte data[] = "hello world".getBytes(StandardCharsets.UTF_8);
561561

562-
final char[] hex = Hex.encodeHex(data, -2, 10, true);
563-
assertArrayEquals("64".toCharArray(), hex);
562+
assertThrows(ArrayIndexOutOfBoundsException.class, () -> Hex.encodeHex(data, -2, 10, true));
564563
}
565564

566-
@Test(expected=ArrayIndexOutOfBoundsException.class)
565+
@Test
567566
public void testEncodeHexPartialInputOverbounds() {
568567
final byte data[] = "hello world".getBytes(StandardCharsets.UTF_8);
569568

570-
final char[] hex = Hex.encodeHex(data, 9, 10, true);
571-
assertArrayEquals("64".toCharArray(), hex);
569+
assertThrows(ArrayIndexOutOfBoundsException.class, () -> Hex.encodeHex(data, 9, 10, true));
572570
}
573571

574572
@Test

0 commit comments

Comments
 (0)