From 9a6c8ed93a5c39eb6fee5f996b4d5d9ff8445883 Mon Sep 17 00:00:00 2001 From: Matthias Andreas Benkard Date: Tue, 28 Dec 2021 01:00:22 +0100 Subject: Add Decoder#ofDictionary. Change-Id: I53873f743ce84d9bf50da4cb5238a6f4d82de986 --- .../java/eu/mulk/jgvariant/core/DecoderTest.java | 34 ++++++++++++++++++++++ 1 file changed, 34 insertions(+) (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 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 @@ -98,6 +98,40 @@ class DecoderTest { decoder.decode(ByteBuffer.wrap(data))); } + @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 = -- cgit v1.2.3