@Test public void testMixedCase() throws Exception { HexDecoder hd = new HexDecoder(); ByteBuffer bb = hd.code(CharBuffer.wrap("00AAaaAaaA99")); Assert.assertEquals(0, bb.get()); Assert.assertEquals((byte) 0xAA, bb.get()); Assert.assertEquals((byte) 0xAA, bb.get()); Assert.assertEquals((byte) 0xAA, bb.get()); Assert.assertEquals((byte) 0xAA, bb.get()); Assert.assertEquals((byte) 0x99, bb.get()); Assert.assertFalse(bb.hasRemaining()); }
protected void test(HexDecoder hd, String encoded, byte[] expected) throws Exception { ByteBuffer bb = hd.code(CharBuffer.wrap(encoded)); byte[] actual = new byte[bb.remaining()]; bb.get(actual); Assert.assertArrayEquals(expected, actual); }