aboutsummaryrefslogtreecommitdiffstats
path: root/csc/strings-test.csc
diff options
context:
space:
mode:
Diffstat (limited to 'csc/strings-test.csc')
-rw-r--r--csc/strings-test.csc52
1 files changed, 29 insertions, 23 deletions
diff --git a/csc/strings-test.csc b/csc/strings-test.csc
index 60bfb08..1f981ad 100644
--- a/csc/strings-test.csc
+++ b/csc/strings-test.csc
@@ -8,16 +8,16 @@
(begin
- (test prefix?-good
- (assert-equal #t (prefix? "asdf" "asdfjkl;")))
+ (test has-prefix?-good
+ (assert-equal #t (has-prefix? "asdfjkl;" "asdf")))
- (test prefix?-bad
- (assert-equal #f (prefix? "asdf" "asdbjkl;")))
+ (test has-prefix?-bad
+ (assert-equal #f (has-prefix? "asdbjkl;" "asdf")))
- (test prefix?-too-long
- (assert-equal #f (prefix? "asdf" "as")))
+ (test has-prefix?-too-long
+ (assert-equal #f (has-prefix? "as" "asdf")))
(test str-quote-simple
@@ -28,46 +28,42 @@
(assert-equal "\"this string \\\" has a quote\"" (str-quote "this string \" has a quote")))
- (test find-ok
- (assert-equal 8 (find "abc" "dabsadfdabcdfdfd")))
+ (test index-ok
+ (assert-equal 8 (index "dabsadfdabcdfdfd" "abc")))
- (test find-one-letter
- (assert-equal 8 (find "a" "sdfdfdfsasdfe")))
+ (test index-one-letter
+ (assert-equal 8 (index "sdfdfdfsasdfe" "a")))
- (test find-notfound
- (let* ((match "a")
- (str "def")
- (got-exception '()))
- (guard (e
- ((not-found-error? e) (set! got-exception e)))
- (find match str))
- (assert (not-found-error? got-exception))))
+ (test index-notfound
+ (assert-equal
+ -1
+ (index "def" "a")))
(test contains
(assert-equal
#t
- (contains "abc" "b")))
+ (contains? "abc" "b")))
(test doesnt-contain
(assert-equal
#f
- (contains "abc" "d")))
+ (contains? "abc" "d")))
(test contains-empty
(assert-equal
#t
- (contains "" "")))
+ (contains? "" "")))
(test empty-contains
(assert-equal
#f
- (contains "" "a")))
+ (contains? "" "a")))
(test join-,
@@ -94,4 +90,14 @@
(test split-trailing-empty
- (assert-equal '("a" "") (split "a " " ")))))
+ (assert-equal '("a" "") (split "a " " ")))
+
+
+ (test split-n
+ (assert-equal '("a" "b" "c d e") (split "a b c d e" " " 3)))
+
+
+ (test split-none
+ (assert-equal
+ '()
+ (split "a b c d e" " " 0)))))