private void testBase32EmptyInputStream(final int chuckSize) throws Exception { final byte[] emptyEncoded = new byte[0]; final byte[] emptyDecoded = new byte[0]; testByteByByte(emptyEncoded, emptyDecoded, chuckSize, CRLF); testByChunk(emptyEncoded, emptyDecoded, chuckSize, CRLF); }
/** * Tests the Base32InputStream implementation against empty input. * * @throws Exception * for some failure scenarios. */ @Test public void testBase32EmptyInputStreamMimeChuckSize() throws Exception { testBase32EmptyInputStream(BaseNCodec.MIME_CHUNK_SIZE); }
/** * Tests the Base32InputStream implementation. * * @throws Exception * for some failure scenarios. */ @Test public void testBase32InputStreamByteByByte() throws Exception { // Hello World test. byte[] encoded = StringUtils.getBytesUtf8(Base32TestData.BASE32_FIXTURE); byte[] decoded = StringUtils.getBytesUtf8(Base32TestData.STRING_FIXTURE); testByteByByte(encoded, decoded, BaseNCodec.MIME_CHUNK_SIZE, CRLF); // Single Byte test. encoded = StringUtils.getBytesUtf8("AA======\r\n"); decoded = new byte[] { (byte) 0 }; testByteByByte(encoded, decoded, BaseNCodec.MIME_CHUNK_SIZE, CRLF); // // Single Line test. // String singleLine = Base32TestData.ENCODED_32_CHARS_PER_LINE.replaceAll("\n", ""); // encoded = StringUtils.getBytesUtf8(singleLine); // decoded = Base32TestData.DECODED; // testByteByByte(encoded, decoded, 0, LF); // test random data of sizes 0 thru 150 final BaseNCodec codec = new Base32(); for (int i = 0; i <= 150; i++) { final byte[][] randomData = Base32TestData.randomData(codec, i); encoded = randomData[1]; decoded = randomData[0]; testByteByByte(encoded, decoded, 0, LF); } }
testByChunk(encoded, decoded, BaseNCodec.MIME_CHUNK_SIZE, CRLF); testByChunk(encoded, decoded, BaseNCodec.MIME_CHUNK_SIZE, CRLF); encoded = randomData[1]; decoded = randomData[0]; testByChunk(encoded, decoded, 0, LF);
/** * Tests the Base32InputStream implementation against empty input. * * @throws Exception * for some failure scenarios. */ @Test public void testBase32EmptyInputStreamPemChuckSize() throws Exception { testBase32EmptyInputStream(BaseNCodec.PEM_CHUNK_SIZE); }