X-Git-Url: http://git.nikiroo.be/?a=blobdiff_plain;f=src%2Fbe%2Fnikiroo%2Futils%2Ftest_code%2FReplaceInputStreamTest.java;h=efab8c73d62e5f79779a41b6f8c4c889ad8a8f74;hb=2e465ed3dc72efcdf96e419b39d6119c0cc41c6c;hp=e6e211215430485cfd0938b5fcb89f6fc5ee4a5e;hpb=b990b0024113b9cd0aab28b556439ae843dd5c36;p=nikiroo-utils.git diff --git a/src/be/nikiroo/utils/test_code/ReplaceInputStreamTest.java b/src/be/nikiroo/utils/test_code/ReplaceInputStreamTest.java index e6e2112..efab8c7 100644 --- a/src/be/nikiroo/utils/test_code/ReplaceInputStreamTest.java +++ b/src/be/nikiroo/utils/test_code/ReplaceInputStreamTest.java @@ -48,7 +48,7 @@ class ReplaceInputStreamTest extends TestLauncher { } }); - addTest(new TestCase("Lnger replace") { + addTest(new TestCase("Longer replace") { @Override public void test() throws Exception { byte[] data = new byte[] { 42, 12, 0, 127 }; @@ -79,22 +79,126 @@ class ReplaceInputStreamTest extends TestLauncher { byte[] data = "I like red".getBytes("UTF-8"); ReplaceInputStream in = new ReplaceInputStream( new ByteArrayInputStream(data), - "red".getBytes("UTF-8"), "blue".getBytes("UTF-8")); + "red", "blue"); 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".getBytes("UTF-8"), "red".getBytes("UTF-8")); + "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 cabage".getBytes("UTF-8"); + ReplaceInputStream in = new ReplaceInputStream( + new ByteArrayInputStream(data), // + 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