### Question:
Base64 { public static byte[] decode(String s) { s = s.replaceAll("\\s+", ""); char[] ca = s.toCharArray(); if (ca.length % 4 != 0) { throw new IllegalArgumentException(); } ByteArrayOutputStream baos = new ByteArrayOutputStream((ca.length * 3 + 3) / 4); for (int i = 0; i < ca.length; i += 4) { if (ca[i + 2] == PAD) { int v1 = val(ca[i]), v2 = val(ca[i + 1]); byte b1 = (byte) ((v1 << 2) | ((v2 >> 4) & 0x03)); baos.write(b1); } else if (ca[i + 3] == PAD) { int v1 = val(ca[i]), v2 = val(ca[i + 1]), v3 = val(ca[i + 2]); byte b1 = (byte) ((v1 << 2) | ((v2 >> 4) & 0x03)); byte b2 = (byte) (((v2 << 4) & 0xF0) | ((v3 >> 2) & 0x0F)); baos.write(b1); baos.write(b2); } else { int v1 = val(ca[i]), v2 = val(ca[i + 1]), v3 = val(ca[i + 2]), v4 = val(ca[i + 3]); byte b1 = (byte) ((v1 << 2) | ((v2 >> 4) & 0x03)); byte b2 = (byte) (((v2 << 4) & 0xF0) | ((v3 >> 2) & 0x0F)); byte b3 = (byte) (((v3 << 6) & 0x40) | v4); baos.write(b1); baos.write(b2); baos.write(b3); } } return baos.toByteArray(); }  static byte[] decode(String s); static final String CHARS; static final char PAD; }### Answer:
@Test public void testDecodeEmpty() { byte[] ba = Base64.decode(""); assertEquals(0, ba.length); }
@Test public void testDecode() throws UnsupportedEncodingException { byte[] ba = Base64.decode("VGVzdA=="); assertEquals("Test", new String(ba, "US-ASCII")); }
@Test public void testDecodeWhitespaceStripped() throws UnsupportedEncodingException { byte[] ba = Base64.decode("VGV\nzdA=="); assertEquals("Test", new String(ba, "US-ASCII")); }
@Test public void testDecodeNoPadding() throws UnsupportedEncodingException { byte[] ba = Base64.decode("QUJD"); assertEquals("ABC", new String(ba, "US-ASCII")); }
@Test public void testDecodeOnePaddingChar() throws UnsupportedEncodingException { byte[] ba = Base64.decode("ISE="); assertEquals("!!", new String(ba, "US-ASCII")); }
@Test(expected = IllegalArgumentException.class) public void testDecodeBadCharacter() { Base64.decode("!!!!"); }
@Test(expected = IllegalArgumentException.class) public void testDecodeBadStringLength() { Base64.decode("ISE"); }