aboutsummaryrefslogtreecommitdiff
path: root/jgvariant-core/src/test
diff options
context:
space:
mode:
authorMatthias Andreas Benkard <code@mail.matthias.benkard.de>2021-12-28 01:00:22 +0100
committerMatthias Andreas Benkard <code@mail.matthias.benkard.de>2021-12-28 01:00:22 +0100
commit9a6c8ed93a5c39eb6fee5f996b4d5d9ff8445883 (patch)
tree5d7f640c99b4da393b531f21c1248634acf34fa2 /jgvariant-core/src/test
parentcd924f6efbb40993eb12ed2c6e6547d8b505d439 (diff)
Add Decoder#ofDictionary.
Change-Id: I53873f743ce84d9bf50da4cb5238a6f4d82de986
Diffstat (limited to 'jgvariant-core/src/test')
-rw-r--r--jgvariant-core/src/test/java/eu/mulk/jgvariant/core/DecoderTest.java34
1 files changed, 34 insertions, 0 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 ab7de44..efbcafa 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
@@ -99,6 +99,40 @@ class DecoderTest {
}
@Test
+ void testDictionary() {
+ var data =
+ new byte[] {
+ 0x68,
+ 0x69,
+ 0x00,
+ 0x00,
+ (byte) 0xfe,
+ (byte) 0xff,
+ (byte) 0xff,
+ (byte) 0xff,
+ 0x03,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x62,
+ 0x79,
+ 0x65,
+ 0x00,
+ (byte) 0xff,
+ (byte) 0xff,
+ (byte) 0xff,
+ (byte) 0xff,
+ 0x04,
+ 0x09,
+ 0x15
+ };
+
+ var decoder =
+ Decoder.ofDictionary(Decoder.ofString(UTF_8), Decoder.ofInt().withByteOrder(LITTLE_ENDIAN));
+ assertEquals(Map.of("hi", -2, "bye", -1), decoder.decode(ByteBuffer.wrap(data)));
+ }
+
+ @Test
void testStringArray() {
var data =
new byte[] {