aboutsummaryrefslogtreecommitdiff
path: root/src/test/java/eu
diff options
context:
space:
mode:
authorMatthias Andreas Benkard <code@mail.matthias.benkard.de>2021-12-14 21:51:10 +0100
committerMatthias Andreas Benkard <code@mail.matthias.benkard.de>2021-12-14 21:51:10 +0100
commit55c34814bc7e6749a1530e7b36b51e0bc6358df3 (patch)
tree6405ff6b5904dc96dd27ecea98ef2b59fa30a4d4 /src/test/java/eu
parent34430180f83a9e52ead4f919731f955bbc3b3b79 (diff)
Remove Variant class, parse variants into Object.
Change-Id: I9b4b3079aea42b74f6fcf6341305b6fded9234f4
Diffstat (limited to 'src/test/java/eu')
-rw-r--r--src/test/java/eu/mulk/jgvariant/core/DecoderTest.java19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/test/java/eu/mulk/jgvariant/core/DecoderTest.java b/src/test/java/eu/mulk/jgvariant/core/DecoderTest.java
index d37f6a2..0e16973 100644
--- a/src/test/java/eu/mulk/jgvariant/core/DecoderTest.java
+++ b/src/test/java/eu/mulk/jgvariant/core/DecoderTest.java
@@ -2,6 +2,8 @@ package eu.mulk.jgvariant.core;
import static java.nio.ByteOrder.LITTLE_ENDIAN;
import static java.nio.charset.StandardCharsets.UTF_8;
+import static org.junit.jupiter.api.Assertions.assertAll;
+import static org.junit.jupiter.api.Assertions.assertArrayEquals;
import static org.junit.jupiter.api.Assertions.assertEquals;
import java.nio.ByteBuffer;
@@ -126,6 +128,23 @@ class DecoderTest {
}
@Test
+ void testNestedStructureVariant() {
+ var data =
+ new byte[] {
+ 0x69, 0x63, 0x61, 0x6E, 0x00, 0x68, 0x61, 0x73, 0x00, 0x73, 0x74, 0x72, 0x69, 0x6E, 0x67,
+ 0x73, 0x3F, 0x00, 0x04, 0x0d, 0x05, 0x00, 0x28, 0x28, 0x79, 0x73, 0x29, 0x61, 0x73, 0x29
+ };
+
+ var decoder = Decoder.ofVariant();
+ var result = (Object[]) decoder.decode(ByteBuffer.wrap(data));
+
+ assertAll(
+ () -> assertEquals(2, result.length),
+ () -> assertArrayEquals(new Object[] {(byte) 0x69, "can"}, (Object[]) result[0]),
+ () -> assertEquals(List.of("has", "strings?"), result[1]));
+ }
+
+ @Test
void testSimpleStructure() {
var data = new byte[] {0x60, 0x70};