summaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit.test
diff options
context:
space:
mode:
Diffstat (limited to 'org.eclipse.jgit.test')
-rw-r--r--org.eclipse.jgit.test/tst/org/eclipse/jgit/util/io/UnionInputStreamTest.java28
1 files changed, 19 insertions, 9 deletions
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/util/io/UnionInputStreamTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/util/io/UnionInputStreamTest.java
index 5fd6816ec7..9fb323c4db 100644
--- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/util/io/UnionInputStreamTest.java
+++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/util/io/UnionInputStreamTest.java
@@ -106,13 +106,21 @@ public class UnionInputStreamTest {
u.add(new ByteArrayInputStream(new byte[] { 4, 5 }));
final byte[] r = new byte[5];
- assertEquals(5, u.read(r, 0, 5));
- assertTrue(Arrays.equals(new byte[] { 1, 0, 2, 3, 4 }, r));
+ assertEquals(3, u.read(r, 0, 5));
+ assertTrue(Arrays.equals(new byte[] { 1, 0, 2, }, slice(r, 3)));
assertEquals(1, u.read(r, 0, 5));
- assertEquals(5, r[0]);
+ assertEquals(3, r[0]);
+ assertEquals(2, u.read(r, 0, 5));
+ assertTrue(Arrays.equals(new byte[] { 4, 5, }, slice(r, 2)));
assertEquals(-1, u.read(r, 0, 5));
}
+ private static byte[] slice(byte[] in, int len) {
+ byte[] r = new byte[len];
+ System.arraycopy(in, 0, r, 0, len);
+ return r;
+ }
+
@Test
public void testArrayConstructor() throws IOException {
final UnionInputStream u = new UnionInputStream(
@@ -121,10 +129,12 @@ public class UnionInputStreamTest {
new ByteArrayInputStream(new byte[] { 4, 5 }));
final byte[] r = new byte[5];
- assertEquals(5, u.read(r, 0, 5));
- assertTrue(Arrays.equals(new byte[] { 1, 0, 2, 3, 4 }, r));
+ assertEquals(3, u.read(r, 0, 5));
+ assertTrue(Arrays.equals(new byte[] { 1, 0, 2, }, slice(r, 3)));
assertEquals(1, u.read(r, 0, 5));
- assertEquals(5, r[0]);
+ assertEquals(3, r[0]);
+ assertEquals(2, u.read(r, 0, 5));
+ assertTrue(Arrays.equals(new byte[] { 4, 5, }, slice(r, 2)));
assertEquals(-1, u.read(r, 0, 5));
}
@@ -143,9 +153,9 @@ public class UnionInputStreamTest {
u.add(new ByteArrayInputStream(new byte[] { 3 }));
u.add(new ByteArrayInputStream(new byte[] { 4, 5 }));
assertEquals(0, u.skip(0));
- assertEquals(4, u.skip(4));
- assertEquals(4, u.read());
- assertEquals(1, u.skip(5));
+ assertEquals(3, u.skip(3));
+ assertEquals(3, u.read());
+ assertEquals(2, u.skip(5));
assertEquals(0, u.skip(5));
assertEquals(-1, u.read());