summaryrefslogtreecommitdiff
path: root/examples/10-transient-0/output/java-junit
diff options
context:
space:
mode:
authorMichael Williamson <mike@zwobble.org>2026-07-11 15:47:22 +0100
committerMichael Williamson <mike@zwobble.org>2026-07-11 15:47:22 +0100
commitf9fe80fa50e6ac0c3121c0dde6420c79973c4ccc (patch)
tree77009b5272acfa7cbfc999bc023fad9970f1404e /examples/10-transient-0/output/java-junit
parentc80835cf60e3d772152fd1873dde76d41fa6cec2 (diff)
Support options in Java transient-0
Diffstat (limited to 'examples/10-transient-0/output/java-junit')
-rw-r--r--examples/10-transient-0/output/java-junit/src/test/java/org/zwobble/example/Transient0Tests.java36
1 files changed, 36 insertions, 0 deletions
diff --git a/examples/10-transient-0/output/java-junit/src/test/java/org/zwobble/example/Transient0Tests.java b/examples/10-transient-0/output/java-junit/src/test/java/org/zwobble/example/Transient0Tests.java
index b7e841c..40acde4 100644
--- a/examples/10-transient-0/output/java-junit/src/test/java/org/zwobble/example/Transient0Tests.java
+++ b/examples/10-transient-0/output/java-junit/src/test/java/org/zwobble/example/Transient0Tests.java
@@ -4,6 +4,7 @@ import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.List;
+import java.util.Optional;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.zwobble.example.types.data.HobgoblinTransient0Data;
@@ -13,6 +14,7 @@ import org.zwobble.example.types.data.StructWithBool;
import org.zwobble.example.types.data.StructWithInt32;
import org.zwobble.example.types.data.StructWithInt64;
import org.zwobble.example.types.data.StructWithList;
+import org.zwobble.example.types.data.StructWithOption;
import org.zwobble.example.types.data.StructWithString;
public class Transient0Tests {
@@ -106,4 +108,38 @@ public class Transient0Tests {
Assertions.assertEquals(value, decodedValue);
}
+
+ @Test
+ public void structWithOptionNone() throws IOException {
+ var value = new StructWithOption(
+ Optional.empty(),
+ Optional.empty()
+ );
+
+ var outputStream = new ByteArrayOutputStream();
+ HobgoblinTransient0Data.encodeStructWithOption(value, outputStream);
+ var bytes = outputStream.toByteArray();
+
+ var inputStream = new ByteArrayInputStream(bytes);
+ var decodedValue = HobgoblinTransient0Data.decodeStructWithOption(inputStream);
+
+ Assertions.assertEquals(value, decodedValue);
+ }
+
+ @Test
+ public void structWithOptionSome() throws IOException {
+ var value = new StructWithOption(
+ Optional.of(10L),
+ Optional.of(new InnerStruct(42, 47))
+ );
+
+ var outputStream = new ByteArrayOutputStream();
+ HobgoblinTransient0Data.encodeStructWithOption(value, outputStream);
+ var bytes = outputStream.toByteArray();
+
+ var inputStream = new ByteArrayInputStream(bytes);
+ var decodedValue = HobgoblinTransient0Data.decodeStructWithOption(inputStream);
+
+ Assertions.assertEquals(value, decodedValue);
+ }
}