// No newLine
String inputString = line1;
NewLineReader r = new NewLineReader(new StringReader(inputString));
LineIterator i = r.iterateLines();
Assert.assertTrue(i.hasNext());
Assert.assertEquals(i.nextLine(), inputString);
Assert.assertFalse(i.hasNext());
Assert.assertNull(r.getInputNewLine());
Assert.assertNull(r.getOutputNewLine());
// Test the actual output
r.reset();
String out1 = IOUtil.toString(r);
Assert.assertEquals(inputString, out1);
// \n NewLine
inputString = line1 + "\n" + line2;
r = new NewLineReader(new StringReader(inputString));
i = r.iterateLines();
Assert.assertEquals(i.next(), line1);
Assert.assertEquals(r.getInputNewLine(), "\n");
Assert.assertEquals(r.getOutputNewLine(), "\n");
Assert.assertEquals(i.next(), line2);
Assert.assertFalse(i.hasNext());
// Test the actual output
r.reset();
String out2 = IOUtil.toString(r);
Assert.assertEquals(inputString, out2);
// \r\n NewLine
inputString = line1 + "\r\n" + line2 + "\r\n";
r = new NewLineReader(new StringReader(inputString));
i = r.iterateLines();
Assert.assertEquals(i.next(), line1);
Assert.assertEquals(r.getInputNewLine(), "\r\n");
Assert.assertEquals(r.getOutputNewLine(), "\r\n");
Assert.assertEquals(i.next(), line2);
Assert.assertFalse(i.hasNext()); // Should not return another line (LineIterator behavior)
// Test the actual output
r.reset();
String out3 = IOUtil.toString(r);
Assert.assertEquals(inputString, out3);
}