From 330cba94de13ef400fac5e9999bad5293af5a708 Mon Sep 17 00:00:00 2001 From: Alexander Lucas Date: Wed, 1 Jan 2025 09:46:22 -0500 Subject: [PATCH] added tests for `take_while`, `rtake_while`. --- tests/core/t_string.ml | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/tests/core/t_string.ml b/tests/core/t_string.ml index 4db9bea5..f1747f1d 100644 --- a/tests/core/t_string.ml +++ b/tests/core/t_string.ml @@ -281,6 +281,18 @@ eq ~printer:CCFun.id "ab\nc\n" (unlines [ "ab"; "c" ]);; q Q.printable_string (fun s -> trim (unlines (lines s)) = trim s);; q Q.printable_string (fun s -> trim (unlines_gen (lines_gen s)) = trim s);; +eq ~printer:CCFun.id "" (take_while (Char.equal 'c') "heloo_cc");; +eq ~printer:CCFun.id "" (take_while (Char.equal 'c') "");; +eq ~printer:CCFun.id "c" (take_while (Char.equal 'c') "c");; +eq ~printer:CCFun.id "ccc" (take_while (Char.equal 'c') "cccujsuy");; +eq ~printer:CCFun.id "THIS" (take_while (fun c -> Char.code c < 91) "THISisNotWHAtIwANTED");; + +eq ~printer:CCFun.id "cc" (rtake_while (Char.equal 'c') "heloo_cc");; +eq ~printer:CCFun.id "" (rtake_while (Char.equal 'c') "");; +eq ~printer:CCFun.id "c" (rtake_while (Char.equal 'c') "c");; +eq ~printer:CCFun.id "" (rtake_while (Char.equal 'c') "cccujsuy");; +eq ~printer:CCFun.id "ANTED" (rtake_while (fun c -> Char.code c < 91) "THISisNotWHAtIwANTED");; + q Q.(small_list small_string) (fun l ->