diff --git a/tests/run_tests.ml b/tests/run_tests.ml index 8a60d681..1fd4d89b 100644 --- a/tests/run_tests.ml +++ b/tests/run_tests.ml @@ -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 ] diff --git a/tests/test_BV.ml b/tests/test_BV.ml deleted file mode 100644 index 289e0728..00000000 --- a/tests/test_BV.ml +++ /dev/null @@ -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 - ] diff --git a/tests/test_bv.ml b/tests/test_bv.ml index b12cd84a..e27d4304 100644 --- a/tests/test_bv.ml +++ b/tests/test_bv.ml @@ -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 + ]