diff options
author | Kevin Ryde <user42@zip.com.au> | 2004-08-14 00:43:56 +0000 |
---|---|---|
committer | Kevin Ryde <user42@zip.com.au> | 2004-08-14 00:43:56 +0000 |
commit | 967c0904a07b02e342df669ee82f486ac2a40459 (patch) | |
tree | b0b4ff626bdb25ffb2facdb737c8c3244da980ba | |
parent | 038a7484b60116f765b6168d3afb7bae652d4030 (diff) | |
download | guile-967c0904a07b02e342df669ee82f486ac2a40459.tar.gz |
(string-any, string-every): Exercise char and charset predicate cases.
-rw-r--r-- | test-suite/tests/srfi-13.test | 228 |
1 files changed, 186 insertions, 42 deletions
diff --git a/test-suite/tests/srfi-13.test b/test-suite/tests/srfi-13.test index bb5c09123..4cd636f3b 100644 --- a/test-suite/tests/srfi-13.test +++ b/test-suite/tests/srfi-13.test @@ -28,34 +28,106 @@ (define exception:strict-infix-grammar (cons 'misc-error "^strict-infix")) +;;; +;;; string-any +;;; + (with-test-prefix "string-any" - (pass-if "no match" - (not (string-any char-upper-case? "abcde"))) + (with-test-prefix "bad char_pred" + + (pass-if-exception "integer" exception:wrong-type-arg + (string-any 123 "abcde")) + + (pass-if-exception "string" exception:wrong-type-arg + (string-any "zzz" "abcde"))) + + (with-test-prefix "char" + + (pass-if "no match" + (not (string-any #\C "abcde"))) + + (pass-if "one match" + (string-any #\C "abCde")) + + (pass-if "more than one match" + (string-any #\X "abXXX")) + + (pass-if "no match, start index" + (not (string-any #\A "Abcde" 1))) + + (pass-if "one match, start index" + (string-any #\C "abCde" 1)) + + (pass-if "more than one match, start index" + (string-any #\X "abXXX" 1)) + + (pass-if "no match, start and end index" + (not (string-any #\X "XbcdX" 1 4))) + + (pass-if "one match, start and end index" + (string-any #\C "abCde" 1 4)) + + (pass-if "more than one match, start and end index" + (string-any #\X "abXXX" 1 4))) + + (with-test-prefix "charset" + + (pass-if "no match" + (not (string-any char-set:upper-case "abcde"))) + + (pass-if "one match" + (string-any char-set:upper-case "abCde")) + + (pass-if "more than one match" + (string-any char-set:upper-case "abCDE")) + + (pass-if "no match, start index" + (not (string-any char-set:upper-case "Abcde" 1))) + + (pass-if "one match, start index" + (string-any char-set:upper-case "abCde" 1)) + + (pass-if "more than one match, start index" + (string-any char-set:upper-case "abCDE" 1)) + + (pass-if "no match, start and end index" + (not (string-any char-set:upper-case "AbcdE" 1 4))) + + (pass-if "one match, start and end index" + (string-any char-set:upper-case "abCde" 1 4)) + + (pass-if "more than one match, start and end index" + (string-any char-set:upper-case "abCDE" 1 4))) + + (with-test-prefix "pred" + + (pass-if "no match" + (not (string-any char-upper-case? "abcde"))) - (pass-if "one match" - (string-any char-upper-case? "abCde")) + (pass-if "one match" + (string-any char-upper-case? "abCde")) - (pass-if "more than one match" - (string-any char-upper-case? "abCDE")) + (pass-if "more than one match" + (string-any char-upper-case? "abCDE")) - (pass-if "no match, start index" - (not (string-any char-upper-case? "Abcde" 1))) + (pass-if "no match, start index" + (not (string-any char-upper-case? "Abcde" 1))) - (pass-if "one match, start index" - (string-any char-upper-case? "abCde" 1)) + (pass-if "one match, start index" + (string-any char-upper-case? "abCde" 1)) - (pass-if "more than one match, start index" - (string-any char-upper-case? "abCDE" 1)) + (pass-if "more than one match, start index" + (string-any char-upper-case? "abCDE" 1)) - (pass-if "no match, start and end index" - (not (string-any char-upper-case? "AbcdE" 1 4))) + (pass-if "no match, start and end index" + (not (string-any char-upper-case? "AbcdE" 1 4))) - (pass-if "one match, start and end index" - (string-any char-upper-case? "abCde" 1 4)) + (pass-if "one match, start and end index" + (string-any char-upper-case? "abCde" 1 4)) - (pass-if "more than one match, start and end index" - (string-any char-upper-case? "abCDE" 1 4))) + (pass-if "more than one match, start and end index" + (string-any char-upper-case? "abCDE" 1 4)))) ;;; ;;; string-every @@ -63,39 +135,111 @@ (with-test-prefix "string-every" - ;; in guile 1.6.4 and earlier string-every incorrectly returned #f on an - ;; empty string - (pass-if "empty string" - (string-every char-upper-case? "")) - (pass-if "empty substring" - (string-every char-upper-case? "abc" 1 1)) + (with-test-prefix "char" + + (pass-if "empty string" + (string-every #\X "")) + + (pass-if "empty substring" + (string-every #\X "abc" 1 1)) + + (pass-if "no match at all" + (not (string-every #\X "abcde"))) + + (pass-if "not all match" + (not (string-every #\X "abXXX"))) + + (pass-if "all match" + (string-every #\X "XXXXX")) + + (pass-if "no match at all, start index" + (not (string-every #\X "Xbcde" 1))) + + (pass-if "not all match, start index" + (not (string-every #\X "XXcde" 1))) + + (pass-if "all match, start index" + (string-every #\X "aXXXX" 1)) + + (pass-if "no match at all, start and end index" + (not (string-every #\X "XbcdX" 1 4))) + + (pass-if "not all match, start and end index" + (not (string-every #\X "XXcde" 1 4))) + + (pass-if "all match, start and end index" + (string-every #\X "aXXXe" 1 4))) + + (with-test-prefix "charset" + + (pass-if "empty string" + (string-every char-set:upper-case "")) + + (pass-if "empty substring" + (string-every char-set:upper-case "abc" 1 1)) + + (pass-if "no match at all" + (not (string-every char-set:upper-case "abcde"))) + + (pass-if "not all match" + (not (string-every char-set:upper-case "abCDE"))) + + (pass-if "all match" + (string-every char-set:upper-case "ABCDE")) + + (pass-if "no match at all, start index" + (not (string-every char-set:upper-case "Abcde" 1))) + + (pass-if "not all match, start index" + (not (string-every char-set:upper-case "ABcde" 1))) + + (pass-if "all match, start index" + (string-every char-set:upper-case "aBCDE" 1)) + + (pass-if "no match at all, start and end index" + (not (string-every char-set:upper-case "AbcdE" 1 4))) + + (pass-if "not all match, start and end index" + (not (string-every char-set:upper-case "ABcde" 1 4))) + + (pass-if "all match, start and end index" + (string-every char-set:upper-case "aBCDe" 1 4))) + + (with-test-prefix "pred" + + ;; in guile 1.6.4 and earlier string-every incorrectly returned #f on an + ;; empty string + (pass-if "empty string" + (string-every char-upper-case? "")) + (pass-if "empty substring" + (string-every char-upper-case? "abc" 1 1)) - (pass-if "no match at all" - (not (string-every char-upper-case? "abcde"))) + (pass-if "no match at all" + (not (string-every char-upper-case? "abcde"))) - (pass-if "not all match" - (not (string-every char-upper-case? "abCDE"))) + (pass-if "not all match" + (not (string-every char-upper-case? "abCDE"))) - (pass-if "all match" - (string-every char-upper-case? "ABCDE")) + (pass-if "all match" + (string-every char-upper-case? "ABCDE")) - (pass-if "no match at all, start index" - (not (string-every char-upper-case? "Abcde" 1))) + (pass-if "no match at all, start index" + (not (string-every char-upper-case? "Abcde" 1))) - (pass-if "not all match, start index" - (not (string-every char-upper-case? "ABcde" 1))) + (pass-if "not all match, start index" + (not (string-every char-upper-case? "ABcde" 1))) - (pass-if "all match, start index" - (string-every char-upper-case? "aBCDE" 1)) + (pass-if "all match, start index" + (string-every char-upper-case? "aBCDE" 1)) - (pass-if "no match at all, start and end index" - (not (string-every char-upper-case? "AbcdE" 1 4))) + (pass-if "no match at all, start and end index" + (not (string-every char-upper-case? "AbcdE" 1 4))) - (pass-if "not all match, start and end index" - (not (string-every char-upper-case? "ABcde" 1 4))) + (pass-if "not all match, start and end index" + (not (string-every char-upper-case? "ABcde" 1 4))) - (pass-if "all match, start and end index" - (string-every char-upper-case? "aBCDe" 1 4))) + (pass-if "all match, start and end index" + (string-every char-upper-case? "aBCDe" 1 4)))) (with-test-prefix "string-tabulate" |