From 7aa81d2a490e161082f3c38c9d0e806d841caca2 Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Sun, 28 Oct 2018 23:18:45 +0100 Subject: sid_test: add unit tests for Sid.create --- sid_test.ml | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/sid_test.ml b/sid_test.ml index 5f9f0b2..0a571c9 100644 --- a/sid_test.ml +++ b/sid_test.ml @@ -16,6 +16,23 @@ let max_sid = Stdint.( Uint64.one ) +let create_ok () = + let w = Sid.WellKnown.everyone + and s = + match Sid.create ~sa:[| Stdint.Uint32.zero |] Stdint.Uint64.one with + | None -> assert_failure "Sid.create failed for S-1-0" + | Some s -> s + in + assert_bool + (Printf.sprintf "[%s] ≠ [%s]" (Sid.to_string s) (Sid.to_string w)) + (Sid.equal s w) + +let create_fail () = + let sas = Array.make 16 Stdint.Uint32.one in + match Sid.create ~sa:sas Stdint.Uint64.zero with + | None -> () + | Some s -> assert_failure ("Sid.create succeeded on invalid sa array") + let sf_parse_ok () = let s = Sid.of_string "S-1-1-0" in let z = Stdint.((Sid.create_unsafe [| Uint32.zero |] Uint64.one)) in -- cgit v1.2.3