@Test public void nonASCIIcharacter() throws Exception { assertEncoded("f","Zg=="); // A-grave assertEncoded("f","Zg=\u0100="); }
@Test public void decodeTrailing2() throws Exception { assertIOException("truncated", "Zm9vYmFy12"); }
@Test public void badPadding() throws Exception { assertIOException("incorrect padding, 4th byte", "Zg=a"); }
@Test public void badLength() throws Exception { assertIOException("truncated", "Zm8=="); }
/** * Tests RFC 4648 section 10 test vectors. * <ul> * <li>BASE64("") = ""</li> * <li>BASE64("f") = "Zg=="</li> * <li>BASE64("fo") = "Zm8="</li> * <li>BASE64("foo") = "Zm9v"</li> * <li>BASE64("foob") = "Zm9vYg=="</li> * <li>BASE64("fooba") = "Zm9vYmE="</li> * <li>BASE64("foobar") = "Zm9vYmFy"</li> * </ul> * * @see <a href="http://tools.ietf.org/html/rfc4648">http://tools.ietf.org/html/rfc4648</a> */ @Test public void rfc4648Section10Decode() throws Exception { assertEncoded("", ""); assertEncoded("f", "Zg=="); assertEncoded("fo", "Zm8="); assertEncoded("foo", "Zm9v"); assertEncoded("foob", "Zm9vYg=="); assertEncoded("fooba", "Zm9vYmE="); assertEncoded("foobar", "Zm9vYmFy"); }
@Test public void decodeTrailing1() throws Exception { assertIOException("truncated", "Zm9vYmFy1"); }
/** * Test our decode with pad character in the middle. * Continues provided that the padding is in the correct place, * i.e. concatenated valid strings decode OK. */ @Test public void decodeWithInnerPad() throws Exception { assertEncoded("Hello WorldHello World", "SGVsbG8gV29ybGQ=SGVsbG8gV29ybGQ="); }
@Test public void decodeTrailing3() throws Exception { assertIOException("truncated", "Zm9vYmFy123"); }
/** * Ignores non-BASE64 bytes. */ @Test public void nonBase64Bytes() throws Exception { assertEncoded("Hello World", "S?G!V%sbG 8g\rV\t\n29ybGQ*="); }
@Test public void badPaddingLeading1() throws Exception { assertIOException("incorrect padding, first two bytes cannot be padding", "=A=="); }
@Test public void decodeTrailingJunk() throws Exception { assertEncoded("foobar", "Zm9vYmFy!!!"); }
@Test public void badPaddingLeading2() throws Exception { assertIOException("incorrect padding, first two bytes cannot be padding", "===="); }