@Test public void inputStreamOffsetCount() throws Exception { sink.writeUtf8("abcde"); InputStream in = source.inputStream(); byte[] bytes = {'z', 'z', 'z', 'z', 'z'}; int read = in.read(bytes, 1, 3); if (factory == ONE_BYTE_AT_A_TIME_FACTORY) { assertEquals(1, read); assertByteArrayEquals("zazzz", bytes); } else { assertEquals(3, read); assertByteArrayEquals("zabcz", bytes); } }
@Test public void inputStream() throws Exception { sink.writeUtf8("abc"); InputStream in = source.inputStream(); byte[] bytes = {'z', 'z', 'z'}; int read = in.read(bytes); if (factory == ONE_BYTE_AT_A_TIME_FACTORY) { assertEquals(1, read); assertByteArrayEquals("azz", bytes); read = in.read(bytes); assertEquals(1, read); assertByteArrayEquals("bzz", bytes); read = in.read(bytes); assertEquals(1, read); assertByteArrayEquals("czz", bytes); } else { assertEquals(3, read); assertByteArrayEquals("abc", bytes); } assertEquals(-1, in.read()); }