blob: 60bfb08fb9c3f117adefb7d5bd1fe5732d283009 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
|
(define-library (csc strings-test)
(import (scheme base)
(only (csc testing)
assert
assert-equal
test)
(csc strings))
(begin
(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 contains
(assert-equal
#t
(contains "abc" "b")))
(test doesnt-contain
(assert-equal
#f
(contains "abc" "d")))
(test contains-empty
(assert-equal
#t
(contains "" "")))
(test empty-contains
(assert-equal
#f
(contains "" "a")))
(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"))))
(test split-empty
(assert-equal '("") (split "" " ")))
(test split
(assert-equal '("a" "b") (split "a b" " ")))
(test split-trailing-empty
(assert-equal '("a" "") (split "a " " ")))))
|