|
9 | 9 | (is (= "tab" (s/reverse "bat")))
|
10 | 10 | (is (= "c\uD834\uDD1Ea" (s/reverse "a\uD834\uDD1Ec"))) ;; U+1D11E MUSICAL SYMBOL G CLEF
|
11 | 11 | )
|
12 |
| - |
| 12 | + |
13 | 13 | (testing "Testing string replace"
|
14 | 14 | (is (= "faabar" (s/replace "foobar" \o \a)))
|
15 | 15 | (is (= "barbarbar" (s/replace "foobarfoo" "foo" "bar")))
|
|
87 | 87 | (is (= "foo" (s/trim-newline "foo\r\n")))
|
88 | 88 | (is (= "foo" (s/trim-newline "foo")))
|
89 | 89 | (is (= "foo\r " (s/trim-newline "foo\r ")))
|
90 |
| - (is (= "" (s/trim-newline ""))))) |
| 90 | + (is (= "" (s/trim-newline "")))) |
| 91 | + |
| 92 | + (testing "Testing string trim-newline" |
| 93 | + (is (= "foo" (s/trim-newline "foo\n"))) |
| 94 | + (is (= "foo" (s/trim-newline "foo\r\n"))) |
| 95 | + (is (= "foo" (s/trim-newline "foo"))) |
| 96 | + (is (= "foo\r " (s/trim-newline "foo\r "))) |
| 97 | + (is (= "" (s/trim-newline "")))) |
| 98 | + |
| 99 | + (testing "Testing string index-of" |
| 100 | + (let [sb "tacos"] |
| 101 | + (is (= 2 (s/index-of sb "c"))) |
| 102 | + (is (= 2 (s/index-of sb \c))) |
| 103 | + (is (= 1 (s/index-of sb "ac"))) |
| 104 | + (is (= 3 (s/index-of sb "o" 2))) |
| 105 | + (is (= 3 (s/index-of sb \o 2))) |
| 106 | + (is (= 3 (s/index-of sb "o" -100))) |
| 107 | + (is (= nil (s/index-of sb "z"))) |
| 108 | + (is (= nil (s/index-of sb \z))) |
| 109 | + (is (= nil (s/index-of sb "z" 2))) |
| 110 | + (is (= nil (s/index-of sb \z 2))) |
| 111 | + (is (= nil (s/index-of sb "z" 100)) |
| 112 | + (is (= nil (s/index-of sb "z" -10)))))) |
| 113 | + |
| 114 | + (testing "Testing string last-index-of" |
| 115 | + (let [sb "banana"] |
| 116 | + (is (= 4 (s/last-index-of sb "n"))) |
| 117 | + (is (= 4 (s/last-index-of sb \n))) |
| 118 | + (is (= 3 (s/last-index-of sb "an"))) |
| 119 | + (is (= 4 (s/last-index-of sb "n" ))) |
| 120 | + (is (= 4 (s/last-index-of sb "n" 5))) |
| 121 | + (is (= 4 (s/last-index-of sb \n 5))) |
| 122 | + (is (= 4 (s/last-index-of sb "n" 500))) |
| 123 | + (is (= nil (s/last-index-of sb "z"))) |
| 124 | + (is (= nil (s/last-index-of sb "z" 1))) |
| 125 | + (is (= nil (s/last-index-of sb \z 1))) |
| 126 | + (is (= nil (s/last-index-of sb "z" 100))) |
| 127 | + (is (= nil (s/last-index-of sb "z" -10))))) |
| 128 | + |
| 129 | + (testing "Testing string starts-with?" |
| 130 | + (is (s/starts-with? "clojure west" "clojure")) |
| 131 | + (is (not (s/starts-with? "conj" "clojure")))) |
| 132 | + |
| 133 | + (testing "Testing string ends-with?" |
| 134 | + (is (s/ends-with? "Clojure West" "West")) |
| 135 | + (is (not (s/ends-with? "Conj" "West")))) |
| 136 | + |
| 137 | + (testing "Testing string includes?" |
| 138 | + (let [sb "Clojure Applied Book"] |
| 139 | + (is (s/includes? sb "Applied")) |
| 140 | + (is (not (s/includes? sb "Living")))))) |
91 | 141 |
|
92 | 142 | (comment
|
93 | 143 |
|
|
0 commit comments