From 707e7def471dbb4565addc40bbce4a715888884e Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Thu, 25 Oct 2018 00:15:58 +0200 Subject: sid_test: unit test packed representation --- sid_test.ml | 36 ++++++++++++++++++++++++++++++++++-- 1 file 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 ) -- cgit v1.2.3