From cd924f6efbb40993eb12ed2c6e6547d8b505d439 Mon Sep 17 00:00:00 2001 From: Matthias Andreas Benkard Date: Tue, 28 Dec 2021 00:46:06 +0100 Subject: Add Decoder#ofDictionaryEntry. Change-Id: Ie78096e1a7cfd3bcfa446e3ababe15b910d0c23c --- .../src/test/java/eu/mulk/jgvariant/core/DecoderTest.java | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'jgvariant-core/src/test/java') diff --git a/jgvariant-core/src/test/java/eu/mulk/jgvariant/core/DecoderTest.java b/jgvariant-core/src/test/java/eu/mulk/jgvariant/core/DecoderTest.java index d72a1b6..ab7de44 100644 --- a/jgvariant-core/src/test/java/eu/mulk/jgvariant/core/DecoderTest.java +++ b/jgvariant-core/src/test/java/eu/mulk/jgvariant/core/DecoderTest.java @@ -11,6 +11,7 @@ import static org.junit.jupiter.api.Assertions.assertThrows; import java.nio.ByteBuffer; import java.text.ParseException; import java.util.List; +import java.util.Map; import java.util.Optional; import org.junit.jupiter.api.Test; @@ -271,7 +272,18 @@ class DecoderTest { } @Test - void testDictionaryEntry() { + void testDictionaryEntryAsMapEntry() { + var data = + new byte[] {0x61, 0x20, 0x6B, 0x65, 0x79, 0x00, 0x00, 0x00, 0x02, 0x02, 0x00, 0x00, 0x06}; + + var decoder = + Decoder.ofDictionaryEntry( + Decoder.ofString(UTF_8), Decoder.ofInt().withByteOrder(LITTLE_ENDIAN)); + assertEquals(Map.entry("a key", 514), decoder.decode(ByteBuffer.wrap(data))); + } + + @Test + void testDictionaryEntryAsRecord() { var data = new byte[] {0x61, 0x20, 0x6B, 0x65, 0x79, 0x00, 0x00, 0x00, 0x02, 0x02, 0x00, 0x00, 0x06}; -- cgit v1.2.3