aboutsummaryrefslogtreecommitdiff
path: root/jgvariant-core/src/test/java
diff options
context:
space:
mode:
authorMatthias Andreas Benkard <code@mail.matthias.benkard.de>2021-12-19 22:56:09 +0100
committerMatthias Andreas Benkard <code@mail.matthias.benkard.de>2021-12-28 00:45:53 +0100
commit4e8423db22a77af394bb519e2a828714ab48898d (patch)
tree91cc55474c67c5be7507080d264cd0f9cff495c2 /jgvariant-core/src/test/java
parent796b19da1b9ef6c1721faa2ddf35100eb01a8a28 (diff)
Add jgvariant-ostree module.
Change-Id: Idf7bacad28d7cf65eb1ddd0994dcc2c2c2a7e18e
Diffstat (limited to 'jgvariant-core/src/test/java')
-rw-r--r--jgvariant-core/src/test/java/eu/mulk/jgvariant/core/DecoderTest.java27
1 files changed, 27 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 5cf1a1c..d72a1b6 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
@@ -242,6 +242,26 @@ class DecoderTest {
}
@Test
+ void testPrimitiveByteArray() {
+ var data = new byte[] {0x04, 0x05, 0x06, 0x07};
+
+ var decoder = Decoder.ofByteArray();
+
+ assertArrayEquals(data, decoder.decode(ByteBuffer.wrap(data)));
+ }
+
+ @Test
+ void testPrimitiveByteArrayRecord() {
+ var data = new byte[] {0x04, 0x05, 0x06, 0x07};
+
+ record TestRecord(byte[] bytes) {}
+
+ var decoder = Decoder.ofStructure(TestRecord.class, Decoder.ofByteArray());
+
+ assertArrayEquals(data, decoder.decode(ByteBuffer.wrap(data)).bytes());
+ }
+
+ @Test
void testIntegerArray() {
var data = new byte[] {0x04, 0x00, 0x00, 0x00, 0x02, 0x01, 0x00, 0x00};
@@ -434,4 +454,11 @@ class DecoderTest {
var signature = Signature.parse(ByteBuffer.wrap(data));
assertEquals("(bynqiuxtdsogvmiai)", signature.toString());
}
+
+ @Test
+ void testMap() {
+ var data = new byte[] {0x0A, 0x0B, 0x0C};
+ var decoder = Decoder.ofByteArray().map(bytes -> bytes.length);
+ assertEquals(3, decoder.decode(ByteBuffer.wrap(data)));
+ }
}