public void testNewDataInput_empty() { byte[] b = new byte[0]; ByteArrayDataInput in = ByteStreams.newDataInput(b); try { in.readInt(); fail("expected exception"); } catch (IllegalStateException expected) { } }
public void testLimit_markNotSet() { byte[] big = newPreFilledByteArray(5); InputStream bin = new ByteArrayInputStream(big); InputStream lin = ByteStreams.limit(bin, 2); try { lin.reset(); fail(); } catch (IOException expected) { assertThat(expected).hasMessageThat().isEqualTo("Mark not set"); } }
public void testLimit_markNotSupported() { InputStream lin = ByteStreams.limit(new UnmarkableInputStream(), 2); try { lin.reset(); fail(); } catch (IOException expected) { assertThat(expected).hasMessageThat().isEqualTo("Mark not supported"); } }
public void testSkipFully() throws IOException { byte[] bytes = newPreFilledByteArray(100); skipHelper(0, 0, new ByteArrayInputStream(bytes)); skipHelper(50, 50, new ByteArrayInputStream(bytes)); skipHelper(50, 50, new SlowSkipper(new ByteArrayInputStream(bytes), 1)); skipHelper(50, 50, new SlowSkipper(new ByteArrayInputStream(bytes), 0)); skipHelper(100, -1, new ByteArrayInputStream(bytes)); try { skipHelper(101, 0, new ByteArrayInputStream(bytes)); fail("expected exception"); } catch (EOFException e) { } }
public void testNewDataInput_readFullyAndThenSome() { ByteArrayDataInput in = ByteStreams.newDataInput(bytes); byte[] actual = new byte[bytes.length * 2]; try { in.readFully(actual); fail("expected exception"); } catch (IllegalStateException ex) { assertThat(ex).hasCauseThat().isInstanceOf(EOFException.class); } }
public void testNewDataInput_offset() { ByteArrayDataInput in = ByteStreams.newDataInput(bytes, 2); assertEquals(0x56787654, in.readInt()); try { in.readInt(); fail("expected exception"); } catch (IllegalStateException expected) { } }
public void testNewDataInput_readByte() { ByteArrayDataInput in = ByteStreams.newDataInput(bytes); for (int i = 0; i < bytes.length; i++) { assertEquals(bytes[i], in.readByte()); } try { in.readByte(); fail("expected exception"); } catch (IllegalStateException ex) { assertThat(ex).hasCauseThat().isInstanceOf(EOFException.class); } }
public void testNewDataInput_readUnsignedByte() { ByteArrayDataInput in = ByteStreams.newDataInput(bytes); for (int i = 0; i < bytes.length; i++) { assertEquals(bytes[i], in.readUnsignedByte()); } try { in.readUnsignedByte(); fail("expected exception"); } catch (IllegalStateException ex) { assertThat(ex).hasCauseThat().isInstanceOf(EOFException.class); } }
fail("expected exception"); } catch (NullPointerException e) { fail("expected exception"); } catch (NullPointerException e) { fail("expected exception"); } catch (IndexOutOfBoundsException e) { fail("expected exception"); } catch (IndexOutOfBoundsException e) { fail("expected exception"); } catch (IndexOutOfBoundsException e) { fail("expected exception"); } catch (IndexOutOfBoundsException e) { fail("expected exception"); } catch (EOFException e) {
public void testNewDataInput_normal() { ByteArrayDataInput in = ByteStreams.newDataInput(bytes); assertEquals(0x12345678, in.readInt()); assertEquals(0x76543210, in.readInt()); try { in.readInt(); fail("expected exception"); } catch (IllegalStateException expected) { } }
public void testLimit_markNotSet() { byte[] big = newPreFilledByteArray(5); InputStream bin = new ByteArrayInputStream(big); InputStream lin = ByteStreams.limit(bin, 2); try { lin.reset(); fail(); } catch (IOException expected) { assertThat(expected).hasMessage("Mark not set"); } }
public void testNewDataInput_empty() { byte[] b = new byte[0]; ByteArrayDataInput in = ByteStreams.newDataInput(b); try { in.readInt(); fail("expected exception"); } catch (IllegalStateException expected) { } }
public void testLimit_markNotSupported() { InputStream lin = ByteStreams.limit(new UnmarkableInputStream(), 2); try { lin.reset(); fail(); } catch (IOException expected) { assertThat(expected).hasMessage("Mark not supported"); } }
public void testSkipFully() throws IOException { byte[] bytes = newPreFilledByteArray(100); skipHelper(0, 0, new ByteArrayInputStream(bytes)); skipHelper(50, 50, new ByteArrayInputStream(bytes)); skipHelper(50, 50, new SlowSkipper(new ByteArrayInputStream(bytes), 1)); skipHelper(50, 50, new SlowSkipper(new ByteArrayInputStream(bytes), 0)); skipHelper(100, -1, new ByteArrayInputStream(bytes)); try { skipHelper(101, 0, new ByteArrayInputStream(bytes)); fail("expected exception"); } catch (EOFException e) { } }
public void testNewDataInput_readFullyAndThenSome() { ByteArrayDataInput in = ByteStreams.newDataInput(bytes); byte[] actual = new byte[bytes.length * 2]; try { in.readFully(actual); fail("expected exception"); } catch (IllegalStateException ex) { assertThat(ex.getCause()).isInstanceOf(EOFException.class); } }
public void testNewDataInput_offset() { ByteArrayDataInput in = ByteStreams.newDataInput(bytes, 2); assertEquals(0x56787654, in.readInt()); try { in.readInt(); fail("expected exception"); } catch (IllegalStateException expected) { } }
public void testNewDataInput_readUnsignedByte() { ByteArrayDataInput in = ByteStreams.newDataInput(bytes); for (int i = 0; i < bytes.length; i++) { assertEquals(bytes[i], in.readUnsignedByte()); } try { in.readUnsignedByte(); fail("expected exception"); } catch (IllegalStateException ex) { assertThat(ex.getCause()).isInstanceOf(EOFException.class); } }
public void testNewDataInput_readByte() { ByteArrayDataInput in = ByteStreams.newDataInput(bytes); for (int i = 0; i < bytes.length; i++) { assertEquals(bytes[i], in.readByte()); } try { in.readByte(); fail("expected exception"); } catch (IllegalStateException ex) { assertThat(ex.getCause()).isInstanceOf(EOFException.class); } }
fail("expected exception"); } catch (NullPointerException e) { fail("expected exception"); } catch (NullPointerException e) { fail("expected exception"); } catch (IndexOutOfBoundsException e) { fail("expected exception"); } catch (IndexOutOfBoundsException e) { fail("expected exception"); } catch (IndexOutOfBoundsException e) { fail("expected exception"); } catch (IndexOutOfBoundsException e) { fail("expected exception"); } catch (EOFException e) {
public void testNewDataInput_normal() { ByteArrayDataInput in = ByteStreams.newDataInput(bytes); assertEquals(0x12345678, in.readInt()); assertEquals(0x76543210, in.readInt()); try { in.readInt(); fail("expected exception"); } catch (IllegalStateException expected) { } }