From b0f673fbbb948fdd15ad32f17ec21f3da0a536d1 Mon Sep 17 00:00:00 2001
From: Simon Cruanes <simon.cruanes.2007@m4x.org>
Date: Fri, 3 Jan 2025 12:54:01 -0500
Subject: [PATCH] add more tests for `CCString.{r,}take_while`

---
 tests/core/t_string.ml | 23 ++++++++++++++++++++++-
 1 file changed, 22 insertions(+), 1 deletion(-)

diff --git a/tests/core/t_string.ml b/tests/core/t_string.ml
index 47f1f00b..6d9cd359 100644
--- a/tests/core/t_string.ml
+++ b/tests/core/t_string.ml
@@ -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);;