a few longer tests for CCFlatHashtbl

This commit is contained in:
Simon Cruanes 2016-06-20 16:19:09 +02:00
parent c5303919bd
commit 3731b9d42f

View file

@ -321,7 +321,7 @@ end
| Add (x,y) -> Printf.sprintf "add(%d,%d)" x y | Add (x,y) -> Printf.sprintf "add(%d,%d)" x y
| Remove x -> Printf.sprintf "remove(%d)" x | Remove x -> Printf.sprintf "remove(%d)" x
let gen_ops = let gen_ops n =
let open Q.Gen in let open Q.Gen in
let gen_op = let gen_op =
frequency frequency
@ -329,9 +329,9 @@ end
; 1, return op_remove <*> small_int ; 1, return op_remove <*> small_int
] ]
in in
list_size (1--300) gen_op list_size (0--n) gen_op
let arb_ops : op list Q.arbitrary = let arb_ops n : op list Q.arbitrary =
let shrink_op o = let shrink_op o =
let open Q.Iter in let open Q.Iter in
match o with match o with
@ -344,7 +344,7 @@ end
let shrink = let shrink =
Q.Shrink.list ~shrink:shrink_op in Q.Shrink.list ~shrink:shrink_op in
let print = Q.Print.list op_pp in let print = Q.Print.list op_pp in
Q.make ~shrink ~print gen_ops Q.make ~shrink ~print (gen_ops n)
module TRef = CCHashtbl.Make(CCInt) module TRef = CCHashtbl.Make(CCInt)
@ -364,12 +364,25 @@ end
*) *)
(* test that the table behaves the same as a normal hashtable *) (* test that the table behaves the same as a normal hashtable *)
(*$QR & ~count:500
arb_ops (fun l -> (*$inject
let test_ops l =
let t = T.create 16 in let t = T.create 16 in
let t' = TRef.create 16 in let t' = TRef.create 16 in
List.iter (op_exec t) l; List.iter (op_exec t) l;
List.iter (op_exec_ref t') l; List.iter (op_exec_ref t') l;
(T.to_list t |> List.sort CCOrd.compare) = (T.to_list t |> List.sort CCOrd.compare) =
(TRef.to_list t' |> List.sort CCOrd.compare)) (TRef.to_list t' |> List.sort CCOrd.compare)
*)
(*$Q & ~count:500
(arb_ops 300) test_ops
*)
(*$Q & ~count:10
(arb_ops 3000) test_ops
*)
(*$Q & ~count:5
(arb_ops 30000) test_ops
*) *)