Skip to content

Commit c0f3359

Browse files
committed
Add more fail tests in encoder
1 parent b6864a4 commit c0f3359

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

src/test/java/at/favre/lib/bytes/BinaryToTextEncodingTest.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,16 @@ public void encodeBaseRadix() throws Exception {
4646
assertEquals("100211", new BinaryToTextEncoding.BaseRadix(16).encode(new byte[]{16, 2, 17}, ByteOrder.BIG_ENDIAN));
4747
assertEquals("110210", new BinaryToTextEncoding.BaseRadix(16).encode(new byte[]{16, 2, 17}, ByteOrder.LITTLE_ENDIAN));
4848
assertNotEquals(new BinaryToTextEncoding.BaseRadix(2).encode(new byte[]{1, 2, 3}, ByteOrder.LITTLE_ENDIAN), new BinaryToTextEncoding.BaseRadix(2).encode(new byte[]{1, 2, 3}, ByteOrder.BIG_ENDIAN));
49+
}
50+
51+
@Test(expected = IllegalArgumentException.class)
52+
public void decodeInvalidRadix116() throws Exception {
53+
new BinaryToTextEncoding.BaseRadix(16).decode("AAI=");
54+
}
4955

56+
@Test(expected = IllegalArgumentException.class)
57+
public void decodeInvalidRadix36() throws Exception {
58+
new BinaryToTextEncoding.BaseRadix(36).decode("AAI=");
5059
}
5160

5261
@Test
@@ -56,4 +65,14 @@ public void encodeBase64() throws Exception {
5665
assertEquals("EQIQ", new BinaryToTextEncoding.Base64Encoding().encode(new byte[]{16, 2, 17}, ByteOrder.LITTLE_ENDIAN));
5766
assertNotEquals(new BinaryToTextEncoding.Base64Encoding().encode(new byte[]{1, 2, 3}, ByteOrder.LITTLE_ENDIAN), new BinaryToTextEncoding.Base64Encoding().encode(new byte[]{1, 2, 3}, ByteOrder.BIG_ENDIAN));
5867
}
68+
69+
@Test(expected = IllegalArgumentException.class)
70+
public void decodeInvalidBase64() throws Exception {
71+
new BinaryToTextEncoding.Base64Encoding().decode("(&´´");
72+
}
73+
74+
@Test(expected = IllegalArgumentException.class)
75+
public void decodeHalfInvalidBase64() throws Exception {
76+
new BinaryToTextEncoding.Base64Encoding().decode("EAI`");
77+
}
5978
}

0 commit comments

Comments
 (0)