aboutsummaryrefslogtreecommitdiff
path: root/jgvariant-core/src/test
diff options
context:
space:
mode:
authorMatthias Andreas Benkard <code@mail.matthias.benkard.de>2021-12-28 00:46:06 +0100
committerMatthias Andreas Benkard <code@mail.matthias.benkard.de>2021-12-28 00:47:33 +0100
commitcd924f6efbb40993eb12ed2c6e6547d8b505d439 (patch)
tree1939a470159ede96b4c34ccee293bbcbe9f4b570 /jgvariant-core/src/test
parent6f993f740fabef330bf1477e39c8bcc00d14a6bd (diff)
Add Decoder#ofDictionaryEntry.
Change-Id: Ie78096e1a7cfd3bcfa446e3ababe15b910d0c23c
Diffstat (limited to 'jgvariant-core/src/test')
-rw-r--r--jgvariant-core/src/test/java/eu/mulk/jgvariant/core/DecoderTest.java14
1 files changed, 13 insertions, 1 deletions
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};