diff options
author | polwex <polwex@sortug.com> | 2025-10-06 23:18:59 +0700 |
---|---|---|
committer | polwex <polwex@sortug.com> | 2025-10-06 23:18:59 +0700 |
commit | 5de3f7a3ad7b0cf63b4a6cbddfc1e26359dea161 (patch) | |
tree | b55b2258123149bed40bd89bbaa58e7da54f3a26 /ocaml/test/old/test_hex.ml | |
parent | fdab65f6dac4ba85ed4749f61970660d1132d453 (diff) |
cleaned up tests
Diffstat (limited to 'ocaml/test/old/test_hex.ml')
-rw-r--r-- | ocaml/test/old/test_hex.ml | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/ocaml/test/old/test_hex.ml b/ocaml/test/old/test_hex.ml new file mode 100644 index 0000000..a228682 --- /dev/null +++ b/ocaml/test/old/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 |