public void testNewLines() throws Exception {
final String STR = "a\nbb\n\nccc\rdddd\r\r\r\n\r\neeeee";
final int STRLENBYTES = STR.getBytes().length;
Text out = new Text();
for (int bufsz = 1; bufsz < STRLENBYTES+1; ++bufsz) {
LineReader in = makeStream(STR, bufsz);
int c = 0;
c += in.readLine(out); //"a"\n
assertEquals("line1 length, bufsz:"+bufsz, 1, out.getLength());
c += in.readLine(out); //"bb"\n
assertEquals("line2 length, bufsz:"+bufsz, 2, out.getLength());
c += in.readLine(out); //""\n
assertEquals("line3 length, bufsz:"+bufsz, 0, out.getLength());
c += in.readLine(out); //"ccc"\r
assertEquals("line4 length, bufsz:"+bufsz, 3, out.getLength());
c += in.readLine(out); //dddd\r
assertEquals("line5 length, bufsz:"+bufsz, 4, out.getLength());
c += in.readLine(out); //""\r
assertEquals("line6 length, bufsz:"+bufsz, 0, out.getLength());
c += in.readLine(out); //""\r\n
assertEquals("line7 length, bufsz:"+bufsz, 0, out.getLength());
c += in.readLine(out); //""\r\n
assertEquals("line8 length, bufsz:"+bufsz, 0, out.getLength());
c += in.readLine(out); //"eeeee"EOF
assertEquals("line9 length, bufsz:"+bufsz, 5, out.getLength());
assertEquals("end of file, bufsz: "+bufsz, 0, in.readLine(out));
assertEquals("total bytes, bufsz: "+bufsz, c, STRLENBYTES);
}
}