1b0064df249726c006d7f7d5c06ba793374d2a0f
1 package be
.nikiroo
.utils
.test_code
;
3 import java
.io
.ByteArrayInputStream
;
4 import java
.io
.InputStream
;
6 import be
.nikiroo
.utils
.IOUtils
;
7 import be
.nikiroo
.utils
.NextableInputStream
;
8 import be
.nikiroo
.utils
.test
.TestCase
;
9 import be
.nikiroo
.utils
.test
.TestLauncher
;
11 public class NextableInputStreamTest
extends TestLauncher
{
12 public NextableInputStreamTest(String
[] args
) {
13 super("NextableInputStream test", args
);
15 addTest(new TestCase("Simple byte array reading") {
17 public void test() throws Exception
{
18 byte[] expected
= new byte[] { 42, 12, 0, 127 };
19 InputStream bin
= new ByteArrayInputStream(expected
);
20 NextableInputStream in
= new NextableInputStream(bin
);
21 byte[] actual
= IOUtils
.toByteArray(in
);
24 "The resulting array has not the same number of items",
25 expected
.length
, actual
.length
);
26 for (int i
= 0; i
< expected
.length
; i
++) {
27 assertEquals("Item " + i
+ " (0-based) is not the same",
28 expected
[i
], actual
[i
]);