X-Git-Url: http://git.nikiroo.be/?a=blobdiff_plain;f=src%2Fbe%2Fnikiroo%2Futils%2Ftest_code%2FBufferedInputStreamTest.java;fp=src%2Fbe%2Fnikiroo%2Futils%2Ftest_code%2FBufferedInputStreamTest.java;h=c715585f7da7afb93633c937672342f5b6ec3fc7;hb=dce410fec00030c0affde7b19bcde6de847fae13;hp=3ba7be8c738d2308215f33b59dbeff02a69a4606;hpb=bd86c2218b4a8befeb9b2789b62e1697993f0b5b;p=nikiroo-utils.git diff --git a/src/be/nikiroo/utils/test_code/BufferedInputStreamTest.java b/src/be/nikiroo/utils/test_code/BufferedInputStreamTest.java index 3ba7be8..c715585 100644 --- a/src/be/nikiroo/utils/test_code/BufferedInputStreamTest.java +++ b/src/be/nikiroo/utils/test_code/BufferedInputStreamTest.java @@ -30,6 +30,75 @@ class BufferedInputStreamTest extends TestLauncher { checkArrays(this, "FIRST", in, expected); } }); + + addTest(new TestCase("Byte array is(byte[])") { + @Override + public void test() throws Exception { + byte[] expected = new byte[] { 42, 12, 0, 127 }; + BufferedInputStream in = new BufferedInputStream(expected); + assertEquals( + "The array should be considered identical to its source", + true, in.is(expected)); + assertEquals( + "The array should be considered different to that one", + false, in.is(new byte[] { 42, 12, 0, 121 })); + in.close(); + } + }); + + addTest(new TestCase("InputStream is(byte[])") { + @Override + public void test() throws Exception { + byte[] expected = new byte[] { 42, 12, 0, 127 }; + BufferedInputStream in = new BufferedInputStream( + new ByteArrayInputStream(expected)); + assertEquals( + "The array should be considered identical to its source", + true, in.is(expected)); + assertEquals( + "The array should be considered different to that one", + false, in.is(new byte[] { 42, 12, 0, 121 })); + in.close(); + } + }); + + addTest(new TestCase("Byte array is(String)") { + @Override + public void test() throws Exception { + String expected = "Testy"; + BufferedInputStream in = new BufferedInputStream( + expected.getBytes("UTF-8")); + assertEquals( + "The array should be considered identical to its source", + true, in.is(expected)); + assertEquals( + "The array should be considered different to that one", + false, in.is("Autre")); + assertEquals( + "The array should be considered different to that one", + false, in.is("Test")); + in.close(); + } + }); + + addTest(new TestCase("InputStream is(String)") { + @Override + public void test() throws Exception { + String expected = "Testy"; + BufferedInputStream in = new BufferedInputStream( + new ByteArrayInputStream(expected.getBytes("UTF-8"))); + assertEquals( + "The array should be considered identical to its source", + true, in.is(expected)); + assertEquals( + "The array should be considered different to that one", + false, in.is("Autre")); + assertEquals( + "The array should be considered different to that one", + false, in.is("Testy.")); + in.close(); + } + }); } static void checkArrays(TestCase test, String prefix, InputStream in,