Skip to content

Commit

Permalink
add more tests for CCString.{r,}take_while
Browse files Browse the repository at this point in the history
  • Loading branch information
c-cube committed Jan 3, 2025
1 parent c6f6a01 commit b0f673f
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion tests/core/t_string.ml
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,28 @@ t @@ fun () -> not (suffix ~suf:"cd" "abcde");;
t @@ fun () -> not (suffix ~suf:"abcd" "cd");;
eq ("ab", "cd") (take_drop 2 "abcd");;
eq ("abc", "") (take_drop 3 "abc");;
eq ("abc", "") (take_drop 5 "abc")
eq ("abc", "") (take_drop 5 "abc");;

q
Q.(printable_string)
(fun s ->
let predicate c = Char.code c mod 2 = 0 in
let prefix = take_while predicate s in
let suffix = drop_while predicate s in
if prefix ^ suffix <> s then
Q.Test.fail_reportf "s=%S, pre=%S, post=%S" s prefix suffix;
true)
;;

q
Q.(printable_string)
(fun s ->
let predicate c = Char.code c mod 2 = 0 in
let prefix = rdrop_while predicate s in
let suffix = rtake_while predicate s in
if prefix ^ suffix <> s then
Q.Test.fail_reportf "s=%S, pre=%S, post=%S" s prefix suffix;
true)

let eq' = eq ~printer:Q.Print.(option string);;

Expand Down

0 comments on commit b0f673f

Please sign in to comment.