diff options
| author | Rose Hogenson <rhogenson@posteo.net> | 2022-01-11 22:01:23 -0800 |
|---|---|---|
| committer | Rose Hogenson <rhogenson@posteo.net> | 2022-01-11 22:01:23 -0800 |
| commit | 68986fe0410584c6934c835bb0ee784655f5f8c5 (patch) | |
| tree | d51bc2f3e09df35ef81b7a0c462ff555b4344701 /csc/strings-test.csc | |
| parent | 4fc8b3c1c9dc4aa730e471708dcab7aed68f5a4b (diff) | |
| download | chromatopelma-68986fe0410584c6934c835bb0ee784655f5f8c5.tar.zst | |
Move scheme compiler into a separate directory.
Diffstat (limited to 'csc/strings-test.csc')
| -rw-r--r-- | csc/strings-test.csc | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/csc/strings-test.csc b/csc/strings-test.csc new file mode 100644 index 0000000..2e6d240 --- /dev/null +++ b/csc/strings-test.csc @@ -0,0 +1,60 @@ +(import (scheme base) + (only (csc testing) + assert + assert-equal + test) + (csc strings)) + + +(test prefix?-good + (assert-equal #t (prefix? "asdf" "asdfjkl;"))) + + +(test prefix?-bad + (assert-equal #f (prefix? "asdf" "asdbjkl;"))) + + +(test prefix?-too-long + (assert-equal #f (prefix? "asdf" "as"))) + + +(test str-quote-simple + (assert-equal "\"hello\"" (str-quote "hello"))) + + +(test str-quote-escape + (assert-equal "\"this string \\\" has a quote\"" (str-quote "this string \" has a quote"))) + + +(test find-ok + (assert-equal 8 (find "abc" "dabsadfdabcdfdfd"))) + + +(test find-one-letter + (assert-equal 8 (find "a" "sdfdfdfsasdfe"))) + + +(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 join-, + (assert-equal "a,b,c" (join "," "a" "b" "c"))) + + +(test join-none + (assert-equal "" (join ","))) + + +(test join-singleton + (assert-equal "x" (join "," "x"))) + + +(test join-empty + (assert-equal "abc" (join "" "a" "b" "c"))) |
