From aa11d82fe887d7c625c8bd0e89e2947e448d8bb4 Mon Sep 17 00:00:00 2001 From: Matthias Andreas Benkard Date: Sun, 10 Dec 2023 09:20:48 +0100 Subject: Add Decoder#encode. Implements: - the encoding part of the GVariant specification - OSTree-specific encoding instructions for static deltas Untested. Change-Id: Idbfd6d7e92a9cdff7d8b138d0ecfa36d4f30eee4 --- .../java/eu/mulk/jgvariant/core/DecoderTest.java | 32 +++++++++++++++++++--- 1 file changed, 28 insertions(+), 4 deletions(-) (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 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, -- cgit v1.2.3