diff options
Diffstat (limited to 'jgvariant-core/src/test/java/eu')
| -rw-r--r-- | jgvariant-core/src/test/java/eu/mulk/jgvariant/core/DecoderTest.java | 27 | 
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))); +  }  } | 
