()
| 611 | } |
| 612 | |
| 613 | public void testReadBytes() throws IOException { |
| 614 | ByteProcessor<byte[]> processor = |
| 615 | new ByteProcessor<byte[]>() { |
| 616 | private final ByteArrayOutputStream out = new ByteArrayOutputStream(); |
| 617 | |
| 618 | @Override |
| 619 | public boolean processBytes(byte[] buffer, int offset, int length) throws IOException { |
| 620 | if (length >= 0) { |
| 621 | out.write(buffer, offset, length); |
| 622 | } |
| 623 | return true; |
| 624 | } |
| 625 | |
| 626 | @Override |
| 627 | public byte[] getResult() { |
| 628 | return out.toByteArray(); |
| 629 | } |
| 630 | }; |
| 631 | |
| 632 | File asciiFile = getTestFile("ascii.txt"); |
| 633 | byte[] result = Files.readBytes(asciiFile, processor); |
| 634 | assertEquals(Bytes.asList(Files.toByteArray(asciiFile)), Bytes.asList(result)); |
| 635 | } |
| 636 | |
| 637 | public void testReadBytes_returnFalse() throws IOException { |
| 638 | ByteProcessor<byte[]> processor = |
nothing calls this directly
no test coverage detected