aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Peter McGoron 2024-12-28 23:06:50 -0500
committerGravatar Peter McGoron 2024-12-28 23:06:50 -0500
commit089a03166ad154ec02143683c06845f7af7d877b (patch)
tree66ab416ba6ab6943324912751b81094194be69d0
parentrefactor tests to check type of exception (diff)
test multi character stringHEADmaster
-rw-r--r--tests/string.scm19
1 files changed, 19 insertions, 0 deletions
diff --git a/tests/string.scm b/tests/string.scm
index e8d2671..a4a30c1 100644
--- a/tests/string.scm
+++ b/tests/string.scm
@@ -55,3 +55,22 @@
(with-exception-check ref-at-end
(iterator-ref next-itr))))))
+(let* ((str "abcd")
+ (itr1 (string-iterator-start str)))
+ (test-group "multiple advance")
+ (let ((itr2 (iterator-advance itr1 1))
+ (itr3 (iterator-advance itr1 2))
+ (itr4 (iterator-advance itr1 3)))
+ (test-assert "itr4 status" (not (iterator-at-end? itr4)))
+ (test "itr1 ref" #\a (iterator-ref itr1))
+ (test "itr2 ref" #\b (iterator-ref itr2))
+ (test "itr3 ref" #\c (iterator-ref itr3))
+ (test "itr4 ref" #\d (iterator-ref itr4))
+ (test-assert "itr2->itr3" (iterator=? itr3
+ (iterator-next itr2)))
+ (test-assert "itr2->itr4" (iterator=? itr4
+ (iterator-advance itr2 2)))
+ (test-assert "itr2 < itr4" (iterator<? itr2 itr4))
+ (test-assert "itr4->itr2" (iterator=? itr2
+ (iterator-advance itr4 -2)))))
+