byte[] buffer = new byte[length];
for (int i = 0; i < length; ++i) {
buffer[i] = (byte) i;
}
byte[] result = new byte[buffer.length];
UnsafeByteArrayInputStream ubais = new UnsafeByteArrayInputStream(buffer);
int index = 0;
int by = ubais.read();
while (by >= 0) {
result[index++] = (byte) (by);
by = ubais.read();
}
assertEquals(length, index);
assertTrue(Arrays.equals(buffer, result));
int length2 = 50;
byte[] buffer2 = new byte[length2];
for (int i = 0; i < length2; ++i) {
buffer2[i] = (byte) (90 + i);
}
byte[] result2 = new byte[buffer2.length];
ubais.reInit(buffer2);
int index2 = 0;
int by2 = ubais.read();
while (by2 >= 0) {
result2[index2++] = (byte) (by2);
by2 = ubais.read();
}
assertEquals(length2, index2);
assertTrue(Arrays.equals(buffer2, result2));
}