From d19c25d5d58944d03011a99ff2dbeaaa29e416d2 Mon Sep 17 00:00:00 2001 From: Linnea Gräf Date: Thu, 14 Nov 2024 02:23:01 +0100 Subject: Add re-encode tests --- gson/src/test/java/moe/nea/jcp/gson/test/TestBasic.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'gson/src/test/java/moe') diff --git a/gson/src/test/java/moe/nea/jcp/gson/test/TestBasic.java b/gson/src/test/java/moe/nea/jcp/gson/test/TestBasic.java index c0e42b6..c525303 100644 --- a/gson/src/test/java/moe/nea/jcp/gson/test/TestBasic.java +++ b/gson/src/test/java/moe/nea/jcp/gson/test/TestBasic.java @@ -6,6 +6,7 @@ import com.google.gson.JsonObject; import com.google.gson.JsonPrimitive; import moe.nea.jcp.gson.GsonCodecs; import moe.nea.jcp.gson.GsonOperations; +import moe.nea.pcj.Codec; import moe.nea.pcj.Decode; import moe.nea.pcj.Result; import moe.nea.pcj.json.JsonLikeError; @@ -37,8 +38,10 @@ public class TestBasic { Assertions.assertEquals(expected, result.valueOrPartial().get()); } - Result decode(Decode, JsonLikeError> decode, JsonElement element) { - return Result.cast(decode.decode(element, GsonOperations.INSTANCE)); + Result decode(Codec, JsonLikeError, JsonLikeError> decode, JsonElement element) { + Result result = Result.cast(decode.decode(element, GsonOperations.INSTANCE)); + result.value().ifPresent(decoded -> Assertions.assertEquals(Result.ok(element), decode.encode(decoded, GsonOperations.INSTANCE))); + return result; } GsonCodecs codecs = GsonCodecs.INSTANCE; -- cgit