(byte[] data, boolean byByte)
| 23 | public class DecodeTest { |
| 24 | |
| 25 | private byte[] decompress(byte[] data, boolean byByte) throws IOException { |
| 26 | byte[] buffer = new byte[65536]; |
| 27 | ByteArrayInputStream input = new ByteArrayInputStream(data); |
| 28 | ByteArrayOutputStream output = new ByteArrayOutputStream(); |
| 29 | InputStream brotliInput = newBrotliInputStream(input); |
| 30 | if (byByte) { |
| 31 | byte[] oneByte = new byte[1]; |
| 32 | while (true) { |
| 33 | int next = brotliInput.read(); |
| 34 | if (next == -1) { |
| 35 | break; |
| 36 | } |
| 37 | oneByte[0] = (byte) next; |
| 38 | output.write(oneByte, 0, 1); |
| 39 | } |
| 40 | } else { |
| 41 | while (true) { |
| 42 | int len = brotliInput.read(buffer, 0, buffer.length); |
| 43 | if (len <= 0) { |
| 44 | break; |
| 45 | } |
| 46 | output.write(buffer, 0, len); |
| 47 | } |
| 48 | } |
| 49 | brotliInput.close(); |
| 50 | return output.toByteArray(); |
| 51 | } |
| 52 | |
| 53 | private void checkDecodeResource(String expected, String compressed) throws IOException { |
| 54 | byte[] expectedBytes = readUniBytes(expected); |
no test coverage detected