12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697 |
- (import
- ;; unit tests
- (srfi srfi-64)
- ;; module to test
- (string-utils))
- (test-begin "string-utils-test")
- (test-group
- "char-to-string-test"
- (test-equal "char->string converts a character to a string"
- "a"
- (char->string #\a)))
- (test-group
- "string-to-char-test"
- (test-equal "string->char convers a string of length 1 to a character"
- #\a
- (string->char "a")))
- (test-group
- "has-prefixp-test"
- (test-assert "has-prefix? recognizes a non-empty prefix of a non-empty string"
- (has-prefix? "abcdef" "abc"))
- (test-assert "has-prefix? recognizes a non-empty non-prefix of an empty string"
- (not (has-prefix? "" "abc")))
- (test-assert "has-prefix? recognizes an empty prefix of a non-empty string"
- (has-prefix? "abc" ""))
- (test-assert "has-prefix? recognizes an empty prefix of an empty string"
- (has-prefix? "" ""))
- (test-assert "has-prefix? recognizes a non-prefix of a non-empty string"
- (not (has-prefix? "abcdef" "def"))))
- (test-group
- "has-suffixp-test"
- (test-assert "has-suffix? recognizes a non-empty suffix of a non-empty string"
- (has-suffix? "abcdef" "def"))
- (test-assert "has-suffix? recognizes a non-empty non-suffix of an empty string"
- (not (has-suffix? "" "abc")))
- (test-assert "has-suffix? recognizes an empty suffix of a non-empty string"
- (has-suffix? "abc" ""))
- (test-assert "has-suffix? recognizes an empty suffix of an empty string"
- (has-suffix? "" ""))
- (test-assert "has-suffix? recognizes a non-suffix of a non-empty string"
- (not (has-suffix? "abcdef" "abc"))))
- (test-group
- "remove-prefix-test-group"
- (test-equal "remove-prefix does not remove other stuff"
- "abcdef"
- (remove-prefix "abcdef" "123"))
- (test-equal "remove-prefix does remove the prefix"
- "def"
- (remove-prefix "abcdef" "abc")))
- (test-group
- "remove-suffix-test-group"
- (test-equal "remove-suffix does not remove other stuff"
- "abcdef"
- (remove-suffix "abcdef" "123"))
- (test-equal "remove-suffix does remove the suffix"
- "abc"
- (remove-suffix "abcdef" "def")))
- (test-group
- "remove-multiple-prefix-test-group"
- (test-equal "remove-multiple-prefix does not remove other stuff"
- "abcabcdef"
- (remove-multiple-prefix "abcabcdef" "bc"))
- (test-equal "remove-multiple-prefix does remove the prefix"
- "def"
- (remove-multiple-prefix "abcabcdef" "abc")))
- (test-group
- "remove-multiple-suffix-test-group"
- (test-equal "remove-multiple-suffix does not remove other stuff"
- "abcabcdef"
- (remove-multiple-suffix "abcabcdef" "bc"))
- (test-equal "remove-multiple-suffix does remove the suffix"
- "abc"
- (remove-multiple-suffix "abcdefdef" "def")))
- (test-end "string-utils-test")
|