@Test(expected = IndexOutOfBoundsException.class) public void readNonexistentEntry() throws IOException { LineWriter lines = new LineWriter(); lines.close(); lines.getLines().get(10); }
@Test public void fillLinesWithIgnoredOffsetAndLength() throws IOException { LineWriter lines = new LineWriter(); lines.write("first line", 5, 100); lines.write("second line", 5, 110); lines.close(); assertThat(lines.getLines(), contains("first line", "second line")); }
@Test public void fillLinesWithCharArraysWithIgnoredOffsetAndLength() throws IOException { LineWriter lines = new LineWriter(); char[] firstLine = { 'f', 'i', 'r', 's', 't', ' ', 'l', 'i', 'n', 'e' }; char[] secondLine = { 's', 'e', 'c', 'o', 'n', 'd', ' ', 'l', 'i', 'n', 'e' }; lines.write(firstLine, 5, 100); lines.write(secondLine, 5, 110); lines.close(); assertThat(lines.getLines(), contains("first line", "second line")); } }
@Test public void fillLines() throws IOException { LineWriter lines = new LineWriter(); lines.write("first line", 0, 10); lines.write("second line", 0, 11); lines.close(); assertThat(lines.getLines(), contains("first line", "second line")); }
@Test public void fillLinesWithCharArrays() throws IOException { LineWriter lines = new LineWriter(); char[] firstLine = { 'f', 'i', 'r', 's', 't', ' ', 'l', 'i', 'n', 'e' }; char[] secondLine = { 's', 'e', 'c', 'o', 'n', 'd', ' ', 'l', 'i', 'n', 'e' }; lines.write(firstLine, 0, 10); lines.write(secondLine, 0, 11); lines.close(); assertThat(lines.getLines(), contains("first line", "second line")); }