From c4b71435d9afdb67450f320f54fb7aa99dcae85e Mon Sep 17 00:00:00 2001 From: polwex Date: Sun, 5 Oct 2025 22:57:55 +0700 Subject: fixed jamcue --- ocaml/test/test_hex.ml | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 ocaml/test/test_hex.ml (limited to 'ocaml/test/test_hex.ml') diff --git a/ocaml/test/test_hex.ml b/ocaml/test/test_hex.ml new file mode 100644 index 0000000..a228682 --- /dev/null +++ b/ocaml/test/test_hex.ml @@ -0,0 +1,26 @@ +open Nock_lib.Noun +open Nock_lib.Serial + +let () = + for i = 0 to 10 do + let n = atom i in + let jammed = jam n in + Printf.printf "jam(%d) = %s (%d bytes)\n" i (bytes_to_hex jammed) (Bytes.length jammed) + done + +let () = + Printf.printf "\nRound-trip tests:\n"; + for i = 0 to 50 do + let n = atom i in + let jammed = jam n in + let cued = cue jammed in + match cued with + | Atom a when Z.equal a (Z.of_int i) -> + Printf.printf "OK: %d\n" i + | Atom a -> + Printf.printf "FAIL: %d -> %s\n" i (Z.to_string a); + exit 1 + | Cell _ -> + Printf.printf "FAIL: %d -> cell\n" i; + exit 1 + done -- cgit v1.2.3