From 385ebecece12ad556683f8c98b8f9d612795737a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hugo=20H=C3=B6rnquist?= Date: Sat, 29 Jan 2022 18:44:07 +0100 Subject: Add span-upto. --- tests/util.scm | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/util.scm b/tests/util.scm index de8d4b2a..6d4ca262 100644 --- a/tests/util.scm +++ b/tests/util.scm @@ -3,7 +3,7 @@ ;;; Code: (((calp util) filter-sorted set/r! - find-min find-max)) + find-min find-max span-upto)) (test-equal "Filter sorted" '(3 4 5) @@ -36,3 +36,13 @@ (test-error 'misc-error (find-extreme '())) + +(call-with-values (lambda () (span-upto 2 char-numeric? (string->list "123456"))) + (lambda (head tail) + (test-equal '(#\1 #\2) head) + (test-equal '(#\3 #\4 #\5 #\6) tail))) + +(call-with-values (lambda () (span-upto 2 char-numeric? (string->list "H123456"))) + (lambda (head tail) + (test-equal '() head) + (test-equal '(#\H #\1 #\2 #\3 #\4 #\5 #\6) tail))) -- cgit v1.2.3