@Test
public void testWriteSingleValue() throws Exception {
val expectedData = newArray();
@Cleanup
val s = createInstance(newArray());
AssertExtensions.assertThrows(
"write() allowed writing at negative position.",
() -> s.write(1, -1),
ex -> ex instanceof IndexOutOfBoundsException);
AssertExtensions.assertThrows(
"write() allowed writing overflow position.",
() -> s.write(1, expectedData.length),
ex -> ex instanceof IndexOutOfBoundsException);
for (int i = 0; i < expectedData.length; i += 3) {
expectedData[i] = (byte) i;
s.write(i, i);
}
byte[] writtenData = getData(s);
Assert.assertArrayEquals("Unexpected Stream contents.", expectedData, writtenData);
}