diff options
author | Matthias Andreas Benkard <code@mail.matthias.benkard.de> | 2023-12-10 09:20:48 +0100 |
---|---|---|
committer | Matthias Andreas Benkard <code@mail.matthias.benkard.de> | 2023-12-10 09:22:48 +0100 |
commit | aa11d82fe887d7c625c8bd0e89e2947e448d8bb4 (patch) | |
tree | 5080d40d3eb6d335916cfc8ef62403417236bcae /jgvariant-core/src/test | |
parent | 04a5ce11203665fe1f03547bcfb6618ec0915c38 (diff) |
Add Decoder#encode.
Implements:
- the encoding part of the GVariant specification
- OSTree-specific encoding instructions for static deltas
Untested.
Change-Id: Idbfd6d7e92a9cdff7d8b138d0ecfa36d4f30eee4
Diffstat (limited to 'jgvariant-core/src/test')
-rw-r--r-- | jgvariant-core/src/test/java/eu/mulk/jgvariant/core/DecoderTest.java | 32 |
1 files changed, 28 insertions, 4 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 6399f6e..068b051 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 @@ -517,21 +517,39 @@ class DecoderTest { @Test void map() { var data = new byte[] {0x0A, 0x0B, 0x0C}; - var decoder = Decoder.ofByteArray().map(bytes -> bytes.length); + var decoder = + Decoder.ofByteArray() + .map( + bytes -> bytes.length, + len -> { + throw new UnsupportedOperationException(); + }); assertEquals(3, decoder.decode(ByteBuffer.wrap(data))); } @Test void contramap() { var data = new byte[] {0x0A, 0x0B, 0x0C}; - var decoder = Decoder.ofByteArray().contramap(bytes -> bytes.slice(1, 1)); + var decoder = + Decoder.ofByteArray() + .contramap( + bytes -> bytes.slice(1, 1), + bytes -> { + throw new UnsupportedOperationException(); + }); assertArrayEquals(new byte[] {0x0B}, decoder.decode(ByteBuffer.wrap(data))); } @Test void predicateTrue() { var data = new byte[] {0x00, 0x01, 0x00}; - var innerDecoder = Decoder.ofShort().contramap(bytes -> bytes.slice(1, 2).order(bytes.order())); + var innerDecoder = + Decoder.ofShort() + .contramap( + bytes -> bytes.slice(1, 2).order(bytes.order()), + bytes -> { + throw new UnsupportedOperationException(); + }); var decoder = Decoder.ofPredicate( byteBuffer -> byteBuffer.get(0) == 0, @@ -543,7 +561,13 @@ class DecoderTest { @Test void predicateFalse() { var data = new byte[] {0x01, 0x01, 0x00}; - var innerDecoder = Decoder.ofShort().contramap(bytes -> bytes.slice(1, 2).order(bytes.order())); + var innerDecoder = + Decoder.ofShort() + .contramap( + bytes -> bytes.slice(1, 2).order(bytes.order()), + bytes -> { + throw new UnsupportedOperationException(); + }); var decoder = Decoder.ofPredicate( byteBuffer -> byteBuffer.get(0) == 0, |