### Question:
ByteLineReader { public byte[] readLine(boolean chop) { ByteArrayOutputStream outStream = new ByteArrayOutputStream(PAGESIZE); while (inStream.available() > 0) { int ch = inStream.read(); if (ch < 0) { break; } if (ch == CR) { continue; } if (ch == LF) { if (chop) { break; } else { outStream.write(ch); break; } } outStream.write(ch); } byte[] line = outStream.toByteArray(); return line; } ByteLineReader(byte[] bytes); int getBytesRead(); int bytesAvailable(); byte[] readLine(boolean chop); byte[] readLine(); static boolean cmpBytes(byte[] a, byte[] b); static byte[] appendLF(byte[] bytesIn); static byte[] copyBytes(byte[] inBytes); static byte[] chopLine(byte[] lineIn); static byte[] trim(byte[] lineIn);  }### Answer:
@Test public void testReadLineNoChop() { ByteLineReader br = new ByteLineReader(lines); byte[] line; line = br.readLine(false); assertTrue(bytesMatchString("\n", line)); line = br.readLine(false); assertTrue(bytesMatchString("abc\n", line)); line = br.readLine(false); assertTrue(bytesMatchString("abc\n", line)); line = br.readLine(false); assertTrue(bytesMatchString("abc\n", line)); line = br.readLine(false); assertTrue(bytesMatchString("\n", line)); line = br.readLine(false); assertTrue(bytesMatchString("x", line)); }
@Test public void testReadLineWithChop() { ByteLineReader br = new ByteLineReader(lines); byte[] line; line = br.readLine(true); assertTrue(bytesMatchString("", line)); line = br.readLine(true); assertTrue(bytesMatchString("abc", line)); line = br.readLine(true); assertTrue(bytesMatchString("abc", line)); line = br.readLine(true); assertTrue(bytesMatchString("abc", line)); line = br.readLine(true); assertTrue(bytesMatchString("", line)); line = br.readLine(true); assertTrue(bytesMatchString("x", line)); }