mirror of
https://github.com/c-cube/ocaml-containers.git
synced 2025-12-06 03:05:28 -05:00
merged BV tests in tests/test_bv.ml
This commit is contained in:
parent
79d4129d11
commit
396a1779bf
3 changed files with 27 additions and 27 deletions
|
|
@ -30,7 +30,7 @@ let suite =
|
|||
let props =
|
||||
QCheck.flatten
|
||||
[ Test_PersistentHashtbl.props
|
||||
; Test_BV.props
|
||||
; Test_bv.props
|
||||
; Test_bencode.props
|
||||
; Test_vector.props
|
||||
]
|
||||
|
|
|
|||
|
|
@ -1,25 +0,0 @@
|
|||
|
||||
open QCheck
|
||||
|
||||
let check_create_cardinal =
|
||||
let gen = Arbitrary.small_int in
|
||||
let prop n = BV.cardinal (BV.create ~size:n true) = n in
|
||||
let name = "bv_create_cardinal" in
|
||||
mk_test ~name ~pp:string_of_int gen prop
|
||||
|
||||
let pp bv = PP.(list string) (List.map string_of_int (BV.to_list bv))
|
||||
|
||||
let check_iter_true =
|
||||
let gen = Arbitrary.(lift BV.of_list (list small_int)) in
|
||||
let prop bv =
|
||||
let l' = Sequence.to_rev_list (BV.iter_true bv) in
|
||||
let bv' = BV.of_list l' in
|
||||
BV.cardinal bv = BV.cardinal bv'
|
||||
in
|
||||
let name = "bv_iter_true" in
|
||||
mk_test ~pp ~size:BV.cardinal ~name gen prop
|
||||
|
||||
let props =
|
||||
[ check_create_cardinal
|
||||
; check_iter_true
|
||||
]
|
||||
|
|
@ -58,7 +58,7 @@ let test_inter () =
|
|||
let test_select () =
|
||||
let bv = BV.of_list [1;2;5;400] in
|
||||
let arr = [|"a"; "b"; "c"; "d"; "e"; "f"|] in
|
||||
let l = List.sort compare (BV.select bv arr) in
|
||||
let l = List.sort compare (BV.selecti bv arr) in
|
||||
assert_equal [("b",1); ("c",2); ("f",5)] l;
|
||||
()
|
||||
|
||||
|
|
@ -71,3 +71,28 @@ let suite = "test_bv" >:::
|
|||
; "test_inter" >:: test_inter
|
||||
; "test_select" >:: test_select
|
||||
]
|
||||
|
||||
open QCheck
|
||||
|
||||
let check_create_cardinal =
|
||||
let gen = Arbitrary.small_int in
|
||||
let prop n = BV.cardinal (BV.create ~size:n true) = n in
|
||||
let name = "bv_create_cardinal" in
|
||||
mk_test ~name ~pp:string_of_int gen prop
|
||||
|
||||
let pp bv = PP.(list string) (List.map string_of_int (BV.to_list bv))
|
||||
|
||||
let check_iter_true =
|
||||
let gen = Arbitrary.(lift BV.of_list (list small_int)) in
|
||||
let prop bv =
|
||||
let l' = Sequence.to_rev_list (BV.iter_true bv) in
|
||||
let bv' = BV.of_list l' in
|
||||
BV.cardinal bv = BV.cardinal bv'
|
||||
in
|
||||
let name = "bv_iter_true" in
|
||||
mk_test ~pp ~size:BV.cardinal ~name gen prop
|
||||
|
||||
let props =
|
||||
[ check_create_cardinal
|
||||
; check_iter_true
|
||||
]
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue