summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilipp Gesang <phg@phi-gamma.net>2018-10-25 00:15:58 +0200
committerPhilipp Gesang <phg@phi-gamma.net>2018-10-28 23:07:08 +0100
commit707e7def471dbb4565addc40bbce4a715888884e (patch)
tree2dd805b03531893c47c934d6b92cfef370621648
parentb9571c4785e227a45a29b1b6f3be6aa944b14e34 (diff)
downloadocaml-sid-707e7def471dbb4565addc40bbce4a715888884e.tar.gz
sid_test: unit test packed representation
-rw-r--r--sid_test.ml36
1 files changed, 34 insertions, 2 deletions
diff --git a/sid_test.ml b/sid_test.ml
index 9812152..137575e 100644
--- a/sid_test.ml
+++ b/sid_test.ml
@@ -79,7 +79,31 @@ let sf_parse_too_long_ok () =
(Printf.sprintf "[%s] ≠ [%s]" (Sid.to_string s2) (Sid.to_string l))
(Sid.equal s2 l)
-let test = "string-format-syntax" >:::
+let pr_encode_null_ok () =
+ let x =
+ Sid.WellKnown.null
+ |> Sid.PacketRep.encode
+ |> Xxd.xxd_of_bytes ~blocklen:2
+ in
+ let expect = "0101 0000 0000 0000 0000 0000" in
+ (* vvcc iiii iiii iiii ssss ssss *)
+ assert_equal
+ ~msg:(Printf.sprintf "[%s] ≠ [%s]" x expect)
+ x expect
+
+let pr_encode_all_ok () =
+ let x =
+ Sid.WellKnown.everyone
+ |> Sid.PacketRep.encode
+ |> Xxd.xxd_of_bytes ~blocklen:2
+ in
+ let expect = "0101 0000 0000 0001 0000 0000" in
+ (* vvcc iiii iiii iiii ssss ssss *)
+ assert_equal
+ ~msg:(Printf.sprintf "[%s] ≠ [%s]" x expect)
+ x expect
+
+let string_format_test = "string-format-syntax" >:::
[ "parse-ok" >:: sf_parse_ok
; "parse-empty-fail" >:: sf_parse_empty_fail
; "parse-junk-fail" >:: sf_parse_junk_fail
@@ -91,5 +115,13 @@ let test = "string-format-syntax" >:::
; "parse-too-long-ok" >:: sf_parse_too_long_ok
]
-let () = ignore (run_test_tt_main test)
+
+let packet_rep_test = "packet-rep" >:::
+ [ "encode-null-ok" >:: pr_encode_null_ok
+ ; "encode-all-ok" >:: pr_encode_all_ok
+ ]
+
+let () =
+ ignore (run_test_tt_main string_format_test);
+ ignore (run_test_tt_main packet_rep_test )