MCPcopy
hub / github.com/google/guava / testReadBytes

Method testReadBytes

guava-tests/test/com/google/common/io/FilesTest.java:613–635  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

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 =

Callers

nothing calls this directly

Calls 5

readBytesMethod · 0.95
asListMethod · 0.95
toByteArrayMethod · 0.95
getTestFileMethod · 0.45
assertEqualsMethod · 0.45

Tested by

no test coverage detected