My working unpac space for OCaml projects in development
1open QCheck
2
3let (|>) x f = f x
4
5let quoted_str = Printf.sprintf "%S"
6
7let run lst =
8 OUnit2.run_test_tt_main (QCheck_runner.to_ounit2_test lst)
9
10let _ = run (
11 let f1 s = Stringext.split_trim_left ~on:"," ~trim:" " s in
12 let f2 s = Stringext.split ~on:',' s |> List.map Stringext.trim_left in
13 let pp str =
14 (quoted_str str) ^ " -> " ^
15 (Print.list quoted_str (f1 str)) ^ " != " ^
16 (Print.list quoted_str (f2 str))
17 in
18 Test.make ~name:"stringext.split_trim_left == split |> trim_left" ~small:String.length
19 ((pair (oneofl [",";" ,";", ";" , "]) (list_of_size (Gen.int_bound 3) printable_string)) |>
20 map (fun (sep,sub) -> String.concat sep sub) |>
21 set_shrink Shrink.string |>
22 set_print pp)
23 (fun s -> f1 s = f2 s)
24)