public void testEncodeUint8() throws IOException { final short[] input = new short[] {0x00, 0x7f, 0x80, 0xff}; final byte[] expected = new byte[] {(byte) 0x00, (byte) 0x7f, (byte) 0x80, (byte) 0xff}; ByteArrayOutputStream output = new ByteArrayOutputStream(expected.length); Encoder e = new Encoder(output); for (short u8 : input) { e.uint8(u8); } Assert.assertArrayEquals(expected, output.toByteArray()); }