public void testDecodeString() throws IOException { final ByteArrayInputStream input = new ByteArrayInputStream( new byte[] { 0x05, 'H', 'e', 'l', 'l', 'o', 0x00, // empty string 0x05, 'W', 'o', 'r', 'l', 'd', 0x15, (byte) 0xe3, (byte) 0x81, (byte) 0x93, (byte) 0xe3, (byte) 0x82, (byte) 0x93, (byte) 0xe3, (byte) 0x81, (byte) 0xab, (byte) 0xe3, (byte) 0x81, (byte) 0xa1, (byte) 0xe3, (byte) 0x81, (byte) 0xaf, (byte) 0xe4, (byte) 0xb8, (byte) 0x96, (byte) 0xe7, (byte) 0x95, (byte) 0x8c }); final String[] expected = new String[] {"Hello", "", "World", "こんにちは世界"}; Decoder d = new Decoder(input); for (String str : expected) { assertEquals(str, d.string()); } }
@Override public void decode(@NotNull Decoder d) throws IOException { assert d.string().equals(dummy); }