merged BV tests in tests/test_bv.ml

This commit is contained in:
Simon Cruanes 2013-11-26 17:41:02 +01:00
parent 79d4129d11
commit 396a1779bf
3 changed files with 27 additions and 27 deletions

View file

@ -30,7 +30,7 @@ let suite =
let props = let props =
QCheck.flatten QCheck.flatten
[ Test_PersistentHashtbl.props [ Test_PersistentHashtbl.props
; Test_BV.props ; Test_bv.props
; Test_bencode.props ; Test_bencode.props
; Test_vector.props ; Test_vector.props
] ]

View file

@ -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
]

View file

@ -58,7 +58,7 @@ let test_inter () =
let test_select () = let test_select () =
let bv = BV.of_list [1;2;5;400] in let bv = BV.of_list [1;2;5;400] in
let arr = [|"a"; "b"; "c"; "d"; "e"; "f"|] 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; assert_equal [("b",1); ("c",2); ("f",5)] l;
() ()
@ -71,3 +71,28 @@ let suite = "test_bv" >:::
; "test_inter" >:: test_inter ; "test_inter" >:: test_inter
; "test_select" >:: test_select ; "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
]