1 package hudson.util; 2 3 import junit.framework.TestCase; 4 5 import java.io.StringWriter ; 6 import java.io.Writer ; 7 import java.io.IOException ; 8 9 12 public class LineEndNormalizingWriterTest extends TestCase { 13 public void test1() throws IOException { 14 StringWriter sw = new StringWriter (); 15 Writer w = new LineEndNormalizingWriter(sw); 16 17 w.write("abc\r\ndef\r"); 18 w.write("\n"); 19 20 assertEquals(sw.toString(),"abc\r\ndef\r\n"); 21 } 22 23 public void test2() throws IOException { 24 StringWriter sw = new StringWriter (); 25 Writer w = new LineEndNormalizingWriter(sw); 26 27 w.write("abc\ndef\n"); 28 w.write("\n"); 29 30 assertEquals(sw.toString(),"abc\r\ndef\r\n\r\n"); 31 } 32 33 public void test3() throws IOException { 34 StringWriter sw = new StringWriter (); 35 Writer w = new LineEndNormalizingWriter(sw); 36 37 w.write("\r\n\n"); 38 39 assertEquals(sw.toString(),"\r\n\r\n"); 40 } 41 } 42 | Popular Tags |