Skip to content

Commit b0f673f

Browse files
committed
add more tests for CCString.{r,}take_while
1 parent c6f6a01 commit b0f673f

File tree

1 file changed

+22
-1
lines changed

1 file changed

+22
-1
lines changed

tests/core/t_string.ml

+22-1
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,28 @@ t @@ fun () -> not (suffix ~suf:"cd" "abcde");;
229229
t @@ fun () -> not (suffix ~suf:"abcd" "cd");;
230230
eq ("ab", "cd") (take_drop 2 "abcd");;
231231
eq ("abc", "") (take_drop 3 "abc");;
232-
eq ("abc", "") (take_drop 5 "abc")
232+
eq ("abc", "") (take_drop 5 "abc");;
233+
234+
q
235+
Q.(printable_string)
236+
(fun s ->
237+
let predicate c = Char.code c mod 2 = 0 in
238+
let prefix = take_while predicate s in
239+
let suffix = drop_while predicate s in
240+
if prefix ^ suffix <> s then
241+
Q.Test.fail_reportf "s=%S, pre=%S, post=%S" s prefix suffix;
242+
true)
243+
;;
244+
245+
q
246+
Q.(printable_string)
247+
(fun s ->
248+
let predicate c = Char.code c mod 2 = 0 in
249+
let prefix = rdrop_while predicate s in
250+
let suffix = rtake_while predicate s in
251+
if prefix ^ suffix <> s then
252+
Q.Test.fail_reportf "s=%S, pre=%S, post=%S" s prefix suffix;
253+
true)
233254

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

0 commit comments

Comments
 (0)