X-Git-Url: http://git.nikiroo.be/?a=blobdiff_plain;f=src%2Fbe%2Fnikiroo%2Futils%2Ftest_code%2FReplaceInputStreamTest.java;h=efab8c73d62e5f79779a41b6f8c4c889ad8a8f74;hb=cfdaf6052ddc5ca44cf19f1f6d9f154cc8443024;hp=d08a91ed779c89502ef8e7d65eca8e47b7fa9ddd;hpb=4a464a06db3158e31c64aa798ddce9df1ec7f5f5;p=fanfix.git diff --git a/src/be/nikiroo/utils/test_code/ReplaceInputStreamTest.java b/src/be/nikiroo/utils/test_code/ReplaceInputStreamTest.java index d08a91e..efab8c7 100644 --- a/src/be/nikiroo/utils/test_code/ReplaceInputStreamTest.java +++ b/src/be/nikiroo/utils/test_code/ReplaceInputStreamTest.java @@ -83,33 +83,122 @@ class ReplaceInputStreamTest extends TestLauncher { checkArrays(this, "FIRST", in, "I like blue".getBytes("UTF-8")); - data = "I like blue".getBytes("UTF-8"); + data = "I like blue hammers".getBytes("UTF-8"); in = new ReplaceInputStream(new ByteArrayInputStream(data), "blue", "red"); - checkArrays(this, "FIRST", in, "I like red".getBytes("UTF-8")); + checkArrays(this, "SECOND", in, "I like red hammers".getBytes("UTF-8")); } }); addTest(new TestCase("Multiple replaces") { @Override public void test() throws Exception { - byte[] data = "I like red".getBytes("UTF-8"); + byte[] data = "I like red cabage".getBytes("UTF-8"); ReplaceInputStream in = new ReplaceInputStream( new ByteArrayInputStream(data), // - new String[] {"like", "red"}, // - new String[] {"dislike", "green"} // + new String[] { "red", "like" }, // + new String[] { "green", "very very much like" } // + ); + + String result = new String(IOUtils.toByteArray(in), "UTF-8"); + assertEquals("I very very much like green cabage", result); + } + }); + + addTest(new TestCase("Multiple replaces") { + @Override + public void test() throws Exception { + String str= ("" // + + "\n" // + + "\n" // + + "
\n" // + + "\n" // + + "\t\n" // + + "\t\n" // + + "\t