Skip to content

Commit 98a85c3

Browse files
committed
Some more Base64 tests
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/codec/trunk@670116 13f79535-47bb-0310-9956-ffa450edef68
1 parent 8494bec commit 98a85c3

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,10 @@ public void testSingletons() {
224224
assertEquals("Zg==",new String(Base64.encodeBase64(new byte[] { (byte)102 })));
225225
assertEquals("Zw==",new String(Base64.encodeBase64(new byte[] { (byte)103 })));
226226
assertEquals("aA==",new String(Base64.encodeBase64(new byte[] { (byte)104 })));
227+
for (int i = -128; i<=127; i++){
228+
byte test[]= {(byte)i};
229+
assertTrue(Arrays.equals(test,Base64.decodeBase64(Base64.encodeBase64(test))));
230+
}
227231
}
228232

229233
public void testSingletonsChunked() {
@@ -334,6 +338,14 @@ public void testSingletonsChunked() {
334338
assertEquals("aA==\r\n",new String(Base64.encodeBase64Chunked(new byte[] { (byte)104 })));
335339
}
336340

341+
public void testPairs(){
342+
assertEquals("AAA=",new String(Base64.encodeBase64(new byte[] { 0, 0 })));
343+
for (int i = -128; i<=127; i++){
344+
byte test[]= {(byte)i, (byte)i};
345+
assertTrue(Arrays.equals(test,Base64.decodeBase64(Base64.encodeBase64(test))));
346+
}
347+
}
348+
337349
public void testTriplets() {
338350
assertEquals("AAAA",new String(Base64.encodeBase64(new byte[] { (byte)0, (byte)0, (byte)0 })));
339351
assertEquals("AAAB",new String(Base64.encodeBase64(new byte[] { (byte)0, (byte)0, (byte)1 })));

0 commit comments

Comments
 (0)