diff options
author | Philipp Gesang <phg@phi-gamma.net> | 2018-10-28 23:18:45 +0100 |
---|---|---|
committer | Philipp Gesang <phg@phi-gamma.net> | 2018-10-30 01:15:03 +0100 |
commit | 7aa81d2a490e161082f3c38c9d0e806d841caca2 (patch) | |
tree | 50c8cdb4a0c590017d3e3475a6e77fc98cd308f2 | |
parent | 1702e79c17b4fa05159afd503f3dcd631c1a86d0 (diff) | |
download | ocaml-sid-7aa81d2a490e161082f3c38c9d0e806d841caca2.tar.gz |
sid_test: add unit tests for Sid.create
-rw-r--r-- | sid_test.ml | 17 |
1 files changed, 17 insertions, 0 deletions
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 |