public void testEncodeUint16() throws IOException { final int[] input = new int[] {0, 0xbeef, 0xc0de}; final byte[] expected = new byte[] { (byte) 0x00, (byte) 0xc0, (byte) 0xbe, (byte) 0xef, (byte) 0xc0, (byte) 0xc0, (byte) 0xde }; ByteArrayOutputStream output = new ByteArrayOutputStream(expected.length); Encoder e = new Encoder(output); for (int u16 : input) { e.uint16(u16); } Assert.assertArrayEquals(expected, output.toByteArray()); }