From 727b09bf8fe6c0b9085d2b61d1f8ed5c81b2fdce Mon Sep 17 00:00:00 2001 From: Michael Williamson Date: Sun, 5 Jul 2026 10:56:48 +0100 Subject: Use JUnit in Java transient-0 example --- .../10-transient-0/output/java-junit/.gitignore | 2 + examples/10-transient-0/output/java-junit/pom.xml | 64 ++++++++++++++++++++++ .../java/org/zwobble/example/Transient0Tests.java | 25 +++++++++ 3 files changed, 91 insertions(+) create mode 100644 examples/10-transient-0/output/java-junit/.gitignore create mode 100644 examples/10-transient-0/output/java-junit/pom.xml create mode 100644 examples/10-transient-0/output/java-junit/src/test/java/org/zwobble/example/Transient0Tests.java (limited to 'examples/10-transient-0/output/java-junit') diff --git a/examples/10-transient-0/output/java-junit/.gitignore b/examples/10-transient-0/output/java-junit/.gitignore new file mode 100644 index 0000000..ff511d4 --- /dev/null +++ b/examples/10-transient-0/output/java-junit/.gitignore @@ -0,0 +1,2 @@ +/src/gen/ +/target/ diff --git a/examples/10-transient-0/output/java-junit/pom.xml b/examples/10-transient-0/output/java-junit/pom.xml new file mode 100644 index 0000000..88ef3e5 --- /dev/null +++ b/examples/10-transient-0/output/java-junit/pom.xml @@ -0,0 +1,64 @@ + + 4.0.0 + + org.zwobble.hobgoblin.examples + example + 1.0-SNAPSHOT + + + UTF-8 + 25 + 25 + + + + + + org.junit + junit-bom + 5.9.3 + pom + import + + + + + + + org.zwobble.precisely + precisely + 0.1.5 + + + org.junit.jupiter + junit-jupiter + test + + + + + + + org.codehaus.mojo + build-helper-maven-plugin + 3.6.1 + + + add-source + generate-sources + + add-source + + + + src/gen/java + + + + + + + + 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 new file mode 100644 index 0000000..4959a5c --- /dev/null +++ b/examples/10-transient-0/output/java-junit/src/test/java/org/zwobble/example/Transient0Tests.java @@ -0,0 +1,25 @@ +package org.zwobble.example; + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.zwobble.example.types.point.Point; +import org.zwobble.example.types.point.HobgoblinTransient0Point; + +public class Transient0Tests { + @Test + public void structWithInt32() throws IOException { + var point = new Point(10, 25); + + var outputStream = new ByteArrayOutputStream(); + HobgoblinTransient0Point.encode(point, outputStream); + var bytes = outputStream.toByteArray(); + + var inputStream = new ByteArrayInputStream(bytes); + var decodedPoint = HobgoblinTransient0Point.decode(inputStream); + + Assertions.assertEquals(point, decodedPoint); + } +} -- cgit v1.2.3