Skip to content

Commit 8ea1ca2

Browse files
test: add roundtrip operation handler to conformance runner
1 parent 1c853ed commit 8ea1ca2

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

tests/test_conformance_v2.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,16 @@ def test_conformance(rel_path, data):
9797
_json_norm(data["expected"]), _json_norm(got)
9898
), f"decode mismatch:\n got: {got}\n exp: {data['expected']}"
9999

100+
elif op == "roundtrip":
101+
# Encode, verify GCF output matches expected, then decode and verify round-trip.
102+
got = encode_generic(data["input"])
103+
if isinstance(data["expected"], str):
104+
assert got == data["expected"], f"encode mismatch:\n got: {got!r}\n exp: {data['expected']!r}"
105+
decoded = decode_generic(got)
106+
assert _structural_equal(
107+
_json_norm(data["input"]), _json_norm(decoded)
108+
), f"round-trip mismatch:\n input: {data['input']}\n decoded: {decoded}"
109+
100110
elif op == "error":
101111
# v3 decoder may surface different error categories for same invalid input.
102112
# The requirement is that it rejects.

0 commit comments

Comments
 (0)