diff options
Diffstat (limited to 'examples/10-transient-0/output/java-junit/src/test/java')
| -rw-r--r-- | examples/10-transient-0/output/java-junit/src/test/java/org/zwobble/example/Transient0Tests.java | 36 |
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); + } } |
