From e9269d207876380249bfa535081657ec08021194 Mon Sep 17 00:00:00 2001 From: Stuart Sierra Date: Mon, 1 Feb 2010 11:53:04 -0500 Subject: Rename test namespaces to match new names. --- .../clojure/contrib/test_contrib/java_utils.clj | 10 -- .../contrib/test_contrib/seq_utils_test.clj | 127 --------------------- .../clojure/contrib/test_contrib/shell_out.clj | 41 ------- .../clojure/contrib/test_contrib/str_utils3.clj | 115 ------------------- .../clojure/contrib/test_contrib/test_java.clj | 10 ++ .../clojure/contrib/test_contrib/test_seq.clj | 127 +++++++++++++++++++++ .../clojure/contrib/test_contrib/test_shell.clj | 41 +++++++ .../clojure/contrib/test_contrib/test_string.clj | 115 +++++++++++++++++++ 8 files changed, 293 insertions(+), 293 deletions(-) delete mode 100644 src/test/clojure/clojure/contrib/test_contrib/java_utils.clj delete mode 100644 src/test/clojure/clojure/contrib/test_contrib/seq_utils_test.clj delete mode 100644 src/test/clojure/clojure/contrib/test_contrib/shell_out.clj delete mode 100644 src/test/clojure/clojure/contrib/test_contrib/str_utils3.clj create mode 100644 src/test/clojure/clojure/contrib/test_contrib/test_java.clj create mode 100644 src/test/clojure/clojure/contrib/test_contrib/test_seq.clj create mode 100644 src/test/clojure/clojure/contrib/test_contrib/test_shell.clj create mode 100644 src/test/clojure/clojure/contrib/test_contrib/test_string.clj diff --git a/src/test/clojure/clojure/contrib/test_contrib/java_utils.clj b/src/test/clojure/clojure/contrib/test_contrib/java_utils.clj deleted file mode 100644 index 2d74343a..00000000 --- a/src/test/clojure/clojure/contrib/test_contrib/java_utils.clj +++ /dev/null @@ -1,10 +0,0 @@ -(ns clojure.contrib.test-contrib.java - (:use clojure.test clojure.contrib.java)) - -(deftest t-as-str - (is (= "foo" (as-str "foo"))) - (is (= "foo" (as-str 'foo))) - (is (= "foo" (as-str :foo))) - (is (= "[1 2 3]" (as-str [1 2 3]))) - (is (= "Hello, World!" (as-str "Hello, " :World \!))) - (is (= (str {:foo :bar}) (as-str {:foo :bar})))) diff --git a/src/test/clojure/clojure/contrib/test_contrib/seq_utils_test.clj b/src/test/clojure/clojure/contrib/test_contrib/seq_utils_test.clj deleted file mode 100644 index 84ffbace..00000000 --- a/src/test/clojure/clojure/contrib/test_contrib/seq_utils_test.clj +++ /dev/null @@ -1,127 +0,0 @@ -(ns clojure.contrib.test-contrib.seq-test - (:use clojure.test - clojure.contrib.seq)) - - -(deftest test-positions - (are [expected pred coll] (= expected (positions pred coll)) - [2] string? [:a :b "c"] - () :d [:a :b :c] - [0 2] #{:d} [:d :a :d :a])) - -;Upon further inspection, flatten behaves... wierd. -;These tests are what passes on August 7, 2009 -(deftest test-flatten-present - (are [expected nested-val] (= (flatten nested-val) expected) - ;simple literals - [] nil - [] 1 - [] 'test - [] :keyword - [] 1/2 - [] #"[\r\n]" - [] true - [] false - ;vectors - [1 2 3 4 5] [[1 2] [3 4 [5]]] - [1 2 3 4 5] [1 2 3 4 5] - [#{1 2} 3 4 5] [#{1 2} 3 4 5] - ;sets - [] #{} - [] #{#{1 2} 3 4 5} - [] #{1 2 3 4 5} - [] #{#{1 2} 3 4 5} - ;lists - [] '() - [1 2 3 4 5] `(1 2 3 4 5) - ;maps - [] {:a 1 :b 2} - [:a 1 :b 2] (seq {:a 1 :b 2}) - [] {[:a :b] 1 :c 2} - [:a :b 1 :c 2] (seq {[:a :b] 1 :c 2}) - [:a 1 2 :b 3] (seq {:a [1 2] :b 3}) - ;Strings - [] "12345" - [\1 \2 \3 \4 \5] (seq "12345") - ;fns - [] count - [count even? odd?] [count even? odd?])) - -(deftest test-separate - (are [test-seq] (= (separate even? test-seq) [[2 4] [1 3 5]]) - [1 2 3 4 5] - #{1 2 3 4 5} - '(1 2 3 4 5))) - -(deftest test-includes? - (is (includes? [1 2 3 4 5] 5)) - (is (not (includes? [1 2 3 4 5] 6)))) - -;Note - this does not make sense for maps and sets, because order is expected -(deftest test-indexed - (are [expected test-seq] (= (indexed test-seq) expected) - [[0 :a] [1 :b] [2 :c] [3 :d]] [:a :b :c :d] - [[0 :a] [1 :b] [2 :c] [3 :d]] '(:a :b :c :d) - [[0 \1] [1 \2] [2 \3] [3 \4]] "1234")) - -(deftest test-group-by - (is (= (group-by even? [1 2 3 4 5]) - {false [1 3 5], true [2 4]}))) - -;Note - this does not make sense for maps and sets, because order is expected -(deftest test-partition-by - (are [test-seq] (= (partition-by (comp even? count) test-seq) - [["a"] ["bb" "cccc" "dd"] ["eee" "f"] ["" "hh"]]) - ["a" "bb" "cccc" "dd" "eee" "f" "" "hh"] - '("a" "bb" "cccc" "dd" "eee" "f" "" "hh")) - (is (=(partition-by #{\a \e \i \o \u} "abcdefghijklm") - [[\a] [\b \c \d] [\e] [\f \g \h] [\i] [\j \k \l \m]]))) - -(deftest test-frequencies - (are [expected test-seq] (= (frequencies test-seq) expected) - {\p 2, \s 4, \i 4, \m 1} "mississippi" - {1 4 2 2 3 1} [1 1 1 1 2 2 3] - {1 4 2 2 3 1} '(1 1 1 1 2 2 3))) - -;Note - this does not make sense for maps and sets, because order is expected -;This is a key differnce between reductions and reduce. -(deftest test-reductions - (is (= (reductions + [1 2 3 4 5]) - [1 3 6 10 15])) - (is (= (reductions + 10 [1 2 3 4 5]) - [10 11 13 16 20 25]))) - -;Note - this does not make sense for maps and sets, because order is expected -(deftest test-rotations - (is (= (rotations [1 2 3 4]) - [[1 2 3 4] - [2 3 4 1] - [3 4 1 2] - [4 1 2 3]]))) - -;Note - this does not make sense for maps and sets, because order is expected -(deftest test-partition-all - (is (= (partition-all 4 [1 2 3 4 5 6 7 8 9]) - [[1 2 3 4] [5 6 7 8] [9]])) - (is (= (partition-all 4 2 [1 2 3 4 5 6 7 8 9]) - [[1 2 3 4] [3 4 5 6] [5 6 7 8] [7 8 9] [9]]))) - -;Thanks to Andy Fingerhut for the idea of testing invariants -(deftest test-shuffle-invariants - (is (= (count (shuffle [1 2 3 4])) 4)) - (let [shuffled-seq (shuffle [1 2 3 4])] - (is (every? #{1 2 3 4} shuffled-seq)))) - -(deftest test-shuffle-distributions - (let [a-statistician-needed-to-do-this? true] - (is a-statistician-needed-to-do-this?))) - -;Thanks to Andy Fingerhut for the idea of testing invariants -(deftest test-rand-elt-invariants - (let [elt (rand-elt [:a :b :c :d])] - (is (#{:a :b :c :d} elt)))) - -;Note - this does not make sense for maps and sets, because order is expected -(deftest test-find-first - (is (= (find-first even? [1 2 3 4 5]) 2)) - (is (= (find-first even? '(1 2 3 4 5)) 2))) diff --git a/src/test/clojure/clojure/contrib/test_contrib/shell_out.clj b/src/test/clojure/clojure/contrib/test_contrib/shell_out.clj deleted file mode 100644 index 7af31deb..00000000 --- a/src/test/clojure/clojure/contrib/test_contrib/shell_out.clj +++ /dev/null @@ -1,41 +0,0 @@ -(ns clojure.contrib.test-contrib.shell - (:use clojure.test - clojure.contrib.shell) - (:import (java.io File))) - -; workaroung to access private parse-args. Better way? -(def parse-args ((ns-interns 'clojure.contrib.shell) 'parse-args)) -(def as-file ((ns-interns 'clojure.contrib.shell) 'as-file)) -(def as-env-string ((ns-interns 'clojure.contrib.shell) 'as-env-string)) - -(deftest test-parse-args - (are [x y] (= x y) - {:cmd [nil] :out "UTF-8" :dir nil :env nil} (parse-args []) - {:cmd ["ls"] :out "UTF-8" :dir nil :env nil} (parse-args ["ls"]) - {:cmd ["ls" "-l"] :out "UTF-8" :dir nil :env nil} (parse-args ["ls" "-l"]) - {:cmd ["ls"] :out "ISO-8859-1" :dir nil :env nil} (parse-args ["ls" :out "ISO-8859-1"]) -)) - -(deftest test-with-sh-dir - (are [x y] (= x y) - nil *sh-dir* - "foo" (with-sh-dir "foo" *sh-dir*))) - -(deftest test-with-sh-env - (are [x y] (= x y) - nil *sh-env* - {:KEY "VAL"} (with-sh-env {:KEY "VAL"} *sh-env*))) - -(deftest test-as-env-string - (are [x y] (= x y) - nil (as-env-string nil) - ["FOO=BAR"] (seq (as-env-string {"FOO" "BAR"})) - ["FOO_SYMBOL=BAR"] (seq (as-env-string {'FOO_SYMBOL "BAR"})) - ["FOO_KEYWORD=BAR"] (seq (as-env-string {:FOO_KEYWORD "BAR"})))) - - -(deftest test-as-file - (are [x y] (= x y) - (File. "foo") (as-file "foo") - nil (as-file nil) - (File. "bar") (as-file (File. "bar")))) \ No newline at end of file diff --git a/src/test/clojure/clojure/contrib/test_contrib/str_utils3.clj b/src/test/clojure/clojure/contrib/test_contrib/str_utils3.clj deleted file mode 100644 index a25c3944..00000000 --- a/src/test/clojure/clojure/contrib/test_contrib/str_utils3.clj +++ /dev/null @@ -1,115 +0,0 @@ -(ns clojure.contrib.test-contrib.string - (:require [clojure.contrib.string :as s]) - (:use clojure.test)) - -(deftest t-codepoints - (is (= (list 102 111 111 65536 98 97 114) - (s/codepoints "foo\uD800\uDC00bar")) - "Handles Unicode supplementary characters")) - -(deftest t-escape - (is (= "<foo&bar>" - (s/escape {\& "&" \< "<" \> ">"} ""))) - (is (= " \\\"foo\\\" " - (s/escape {\" "\\\""} " \"foo\" " ))) - (is (= "faabor" (s/escape {\a \o, \o \a} "foobar")))) - -(deftest t-blank - (is (s/blank? nil)) - (is (s/blank? "")) - (is (s/blank? " ")) - (is (s/blank? " \t \n \r ")) - (is (not (s/blank? " foo ")))) - -(deftest t-take - (is (= "foo" (s/take 3 "foobar"))) - (is (= "foobar" (s/take 7 "foobar"))) - (is (= "" (s/take 0 "foo")))) - -(deftest t-drop - (is (= "bar" (s/drop 3 "foobar"))) - (is (= "" (s/drop 9 "foobar"))) - (is (= "foobar" (s/drop 0 "foobar")))) - -(deftest t-butlast - (is (= "foob" (s/butlast 2 "foobar"))) - (is (= "" (s/butlast 9 "foobar"))) - (is (= "foobar" (s/butlast 0 "foobar")))) - -(deftest t-tail - (is (= "ar" (s/tail 2 "foobar"))) - (is (= "foobar" (s/tail 9 "foobar"))) - (is (= "" (s/tail 0 "foobar")))) - -(deftest t-repeat - (is (= "foofoofoo" (s/repeat 3 "foo")))) - -(deftest t-reverse - (is (= "tab" (s/reverse "bat")))) - -(deftest t-replace - (is (= "faabar" (s/replace-char \o \a "foobar"))) - (is (= "barbarbar" (s/replace-str "foo" "bar" "foobarfoo"))) - (is (= "FOObarFOO" (s/replace-by #"foo" s/upper-case "foobarfoo")))) - -(deftest t-replace-first - (is (= "barbarfoo" (s/replace-first-re #"foo" "bar" "foobarfoo"))) - (is (= "FOObarfoo" (s/replace-first-by #"foo" s/upper-case "foobarfoo")))) - -(deftest t-partition - (is (= (list "" "abc" "123" "def") - (s/partition #"[a-z]+" "abc123def")))) - -(deftest t-join - (is (= "1,2,3" (s/join \, [1 2 3]))) - (is (= "" (s/join \, []))) - (is (= "1 and-a 2 and-a 3" (s/join " and-a " [1 2 3])))) - -(deftest t-chop - (is (= "fo" (s/chop "foo"))) - (is (= "") (s/chop "f")) - (is (= "") (s/chop ""))) - -(deftest t-chomp - (is (= "foo" (s/chomp "foo\n"))) - (is (= "foo" (s/chomp "foo\r\n"))) - (is (= "foo" (s/chomp "foo"))) - (is (= "" (s/chomp "")))) - -(deftest t-swap-case - (is (= "fOO!bAR" (s/swap-case "Foo!Bar"))) - (is (= "" (s/swap-case "")))) - -(deftest t-capitalize - (is (= "Foobar" (s/capitalize "foobar"))) - (is (= "Foobar" (s/capitalize "FOOBAR")))) - -(deftest t-ltrim - (is (= "foo " (s/ltrim " foo "))) - (is (= "" (s/ltrim " ")))) - -(deftest t-rtrim - (is (= " foo" (s/rtrim " foo "))) - (is (= "" (s/rtrim " ")))) - -(deftest t-split-lines - (is (= (list "one" "two" "three") - (s/split-lines "one\ntwo\r\nthree"))) - (is (= (list "foo") (s/split-lines "foo")))) - -(deftest t-upper-case - (is (= "FOOBAR" (s/upper-case "Foobar")))) - -(deftest t-lower-case - (is (= "foobar" (s/lower-case "FooBar")))) - -(deftest t-trim - (is (= "foo" (s/trim " foo \r\n")))) - -(deftest t-substring - (is (s/substring? "foo" "foobar")) - (is (not (s/substring? "baz" "foobar")))) - -(deftest t-get - (is (= \o (s/get "foo" 1)))) - diff --git a/src/test/clojure/clojure/contrib/test_contrib/test_java.clj b/src/test/clojure/clojure/contrib/test_contrib/test_java.clj new file mode 100644 index 00000000..2d74343a --- /dev/null +++ b/src/test/clojure/clojure/contrib/test_contrib/test_java.clj @@ -0,0 +1,10 @@ +(ns clojure.contrib.test-contrib.java + (:use clojure.test clojure.contrib.java)) + +(deftest t-as-str + (is (= "foo" (as-str "foo"))) + (is (= "foo" (as-str 'foo))) + (is (= "foo" (as-str :foo))) + (is (= "[1 2 3]" (as-str [1 2 3]))) + (is (= "Hello, World!" (as-str "Hello, " :World \!))) + (is (= (str {:foo :bar}) (as-str {:foo :bar})))) diff --git a/src/test/clojure/clojure/contrib/test_contrib/test_seq.clj b/src/test/clojure/clojure/contrib/test_contrib/test_seq.clj new file mode 100644 index 00000000..84ffbace --- /dev/null +++ b/src/test/clojure/clojure/contrib/test_contrib/test_seq.clj @@ -0,0 +1,127 @@ +(ns clojure.contrib.test-contrib.seq-test + (:use clojure.test + clojure.contrib.seq)) + + +(deftest test-positions + (are [expected pred coll] (= expected (positions pred coll)) + [2] string? [:a :b "c"] + () :d [:a :b :c] + [0 2] #{:d} [:d :a :d :a])) + +;Upon further inspection, flatten behaves... wierd. +;These tests are what passes on August 7, 2009 +(deftest test-flatten-present + (are [expected nested-val] (= (flatten nested-val) expected) + ;simple literals + [] nil + [] 1 + [] 'test + [] :keyword + [] 1/2 + [] #"[\r\n]" + [] true + [] false + ;vectors + [1 2 3 4 5] [[1 2] [3 4 [5]]] + [1 2 3 4 5] [1 2 3 4 5] + [#{1 2} 3 4 5] [#{1 2} 3 4 5] + ;sets + [] #{} + [] #{#{1 2} 3 4 5} + [] #{1 2 3 4 5} + [] #{#{1 2} 3 4 5} + ;lists + [] '() + [1 2 3 4 5] `(1 2 3 4 5) + ;maps + [] {:a 1 :b 2} + [:a 1 :b 2] (seq {:a 1 :b 2}) + [] {[:a :b] 1 :c 2} + [:a :b 1 :c 2] (seq {[:a :b] 1 :c 2}) + [:a 1 2 :b 3] (seq {:a [1 2] :b 3}) + ;Strings + [] "12345" + [\1 \2 \3 \4 \5] (seq "12345") + ;fns + [] count + [count even? odd?] [count even? odd?])) + +(deftest test-separate + (are [test-seq] (= (separate even? test-seq) [[2 4] [1 3 5]]) + [1 2 3 4 5] + #{1 2 3 4 5} + '(1 2 3 4 5))) + +(deftest test-includes? + (is (includes? [1 2 3 4 5] 5)) + (is (not (includes? [1 2 3 4 5] 6)))) + +;Note - this does not make sense for maps and sets, because order is expected +(deftest test-indexed + (are [expected test-seq] (= (indexed test-seq) expected) + [[0 :a] [1 :b] [2 :c] [3 :d]] [:a :b :c :d] + [[0 :a] [1 :b] [2 :c] [3 :d]] '(:a :b :c :d) + [[0 \1] [1 \2] [2 \3] [3 \4]] "1234")) + +(deftest test-group-by + (is (= (group-by even? [1 2 3 4 5]) + {false [1 3 5], true [2 4]}))) + +;Note - this does not make sense for maps and sets, because order is expected +(deftest test-partition-by + (are [test-seq] (= (partition-by (comp even? count) test-seq) + [["a"] ["bb" "cccc" "dd"] ["eee" "f"] ["" "hh"]]) + ["a" "bb" "cccc" "dd" "eee" "f" "" "hh"] + '("a" "bb" "cccc" "dd" "eee" "f" "" "hh")) + (is (=(partition-by #{\a \e \i \o \u} "abcdefghijklm") + [[\a] [\b \c \d] [\e] [\f \g \h] [\i] [\j \k \l \m]]))) + +(deftest test-frequencies + (are [expected test-seq] (= (frequencies test-seq) expected) + {\p 2, \s 4, \i 4, \m 1} "mississippi" + {1 4 2 2 3 1} [1 1 1 1 2 2 3] + {1 4 2 2 3 1} '(1 1 1 1 2 2 3))) + +;Note - this does not make sense for maps and sets, because order is expected +;This is a key differnce between reductions and reduce. +(deftest test-reductions + (is (= (reductions + [1 2 3 4 5]) + [1 3 6 10 15])) + (is (= (reductions + 10 [1 2 3 4 5]) + [10 11 13 16 20 25]))) + +;Note - this does not make sense for maps and sets, because order is expected +(deftest test-rotations + (is (= (rotations [1 2 3 4]) + [[1 2 3 4] + [2 3 4 1] + [3 4 1 2] + [4 1 2 3]]))) + +;Note - this does not make sense for maps and sets, because order is expected +(deftest test-partition-all + (is (= (partition-all 4 [1 2 3 4 5 6 7 8 9]) + [[1 2 3 4] [5 6 7 8] [9]])) + (is (= (partition-all 4 2 [1 2 3 4 5 6 7 8 9]) + [[1 2 3 4] [3 4 5 6] [5 6 7 8] [7 8 9] [9]]))) + +;Thanks to Andy Fingerhut for the idea of testing invariants +(deftest test-shuffle-invariants + (is (= (count (shuffle [1 2 3 4])) 4)) + (let [shuffled-seq (shuffle [1 2 3 4])] + (is (every? #{1 2 3 4} shuffled-seq)))) + +(deftest test-shuffle-distributions + (let [a-statistician-needed-to-do-this? true] + (is a-statistician-needed-to-do-this?))) + +;Thanks to Andy Fingerhut for the idea of testing invariants +(deftest test-rand-elt-invariants + (let [elt (rand-elt [:a :b :c :d])] + (is (#{:a :b :c :d} elt)))) + +;Note - this does not make sense for maps and sets, because order is expected +(deftest test-find-first + (is (= (find-first even? [1 2 3 4 5]) 2)) + (is (= (find-first even? '(1 2 3 4 5)) 2))) diff --git a/src/test/clojure/clojure/contrib/test_contrib/test_shell.clj b/src/test/clojure/clojure/contrib/test_contrib/test_shell.clj new file mode 100644 index 00000000..7af31deb --- /dev/null +++ b/src/test/clojure/clojure/contrib/test_contrib/test_shell.clj @@ -0,0 +1,41 @@ +(ns clojure.contrib.test-contrib.shell + (:use clojure.test + clojure.contrib.shell) + (:import (java.io File))) + +; workaroung to access private parse-args. Better way? +(def parse-args ((ns-interns 'clojure.contrib.shell) 'parse-args)) +(def as-file ((ns-interns 'clojure.contrib.shell) 'as-file)) +(def as-env-string ((ns-interns 'clojure.contrib.shell) 'as-env-string)) + +(deftest test-parse-args + (are [x y] (= x y) + {:cmd [nil] :out "UTF-8" :dir nil :env nil} (parse-args []) + {:cmd ["ls"] :out "UTF-8" :dir nil :env nil} (parse-args ["ls"]) + {:cmd ["ls" "-l"] :out "UTF-8" :dir nil :env nil} (parse-args ["ls" "-l"]) + {:cmd ["ls"] :out "ISO-8859-1" :dir nil :env nil} (parse-args ["ls" :out "ISO-8859-1"]) +)) + +(deftest test-with-sh-dir + (are [x y] (= x y) + nil *sh-dir* + "foo" (with-sh-dir "foo" *sh-dir*))) + +(deftest test-with-sh-env + (are [x y] (= x y) + nil *sh-env* + {:KEY "VAL"} (with-sh-env {:KEY "VAL"} *sh-env*))) + +(deftest test-as-env-string + (are [x y] (= x y) + nil (as-env-string nil) + ["FOO=BAR"] (seq (as-env-string {"FOO" "BAR"})) + ["FOO_SYMBOL=BAR"] (seq (as-env-string {'FOO_SYMBOL "BAR"})) + ["FOO_KEYWORD=BAR"] (seq (as-env-string {:FOO_KEYWORD "BAR"})))) + + +(deftest test-as-file + (are [x y] (= x y) + (File. "foo") (as-file "foo") + nil (as-file nil) + (File. "bar") (as-file (File. "bar")))) \ No newline at end of file diff --git a/src/test/clojure/clojure/contrib/test_contrib/test_string.clj b/src/test/clojure/clojure/contrib/test_contrib/test_string.clj new file mode 100644 index 00000000..a25c3944 --- /dev/null +++ b/src/test/clojure/clojure/contrib/test_contrib/test_string.clj @@ -0,0 +1,115 @@ +(ns clojure.contrib.test-contrib.string + (:require [clojure.contrib.string :as s]) + (:use clojure.test)) + +(deftest t-codepoints + (is (= (list 102 111 111 65536 98 97 114) + (s/codepoints "foo\uD800\uDC00bar")) + "Handles Unicode supplementary characters")) + +(deftest t-escape + (is (= "<foo&bar>" + (s/escape {\& "&" \< "<" \> ">"} ""))) + (is (= " \\\"foo\\\" " + (s/escape {\" "\\\""} " \"foo\" " ))) + (is (= "faabor" (s/escape {\a \o, \o \a} "foobar")))) + +(deftest t-blank + (is (s/blank? nil)) + (is (s/blank? "")) + (is (s/blank? " ")) + (is (s/blank? " \t \n \r ")) + (is (not (s/blank? " foo ")))) + +(deftest t-take + (is (= "foo" (s/take 3 "foobar"))) + (is (= "foobar" (s/take 7 "foobar"))) + (is (= "" (s/take 0 "foo")))) + +(deftest t-drop + (is (= "bar" (s/drop 3 "foobar"))) + (is (= "" (s/drop 9 "foobar"))) + (is (= "foobar" (s/drop 0 "foobar")))) + +(deftest t-butlast + (is (= "foob" (s/butlast 2 "foobar"))) + (is (= "" (s/butlast 9 "foobar"))) + (is (= "foobar" (s/butlast 0 "foobar")))) + +(deftest t-tail + (is (= "ar" (s/tail 2 "foobar"))) + (is (= "foobar" (s/tail 9 "foobar"))) + (is (= "" (s/tail 0 "foobar")))) + +(deftest t-repeat + (is (= "foofoofoo" (s/repeat 3 "foo")))) + +(deftest t-reverse + (is (= "tab" (s/reverse "bat")))) + +(deftest t-replace + (is (= "faabar" (s/replace-char \o \a "foobar"))) + (is (= "barbarbar" (s/replace-str "foo" "bar" "foobarfoo"))) + (is (= "FOObarFOO" (s/replace-by #"foo" s/upper-case "foobarfoo")))) + +(deftest t-replace-first + (is (= "barbarfoo" (s/replace-first-re #"foo" "bar" "foobarfoo"))) + (is (= "FOObarfoo" (s/replace-first-by #"foo" s/upper-case "foobarfoo")))) + +(deftest t-partition + (is (= (list "" "abc" "123" "def") + (s/partition #"[a-z]+" "abc123def")))) + +(deftest t-join + (is (= "1,2,3" (s/join \, [1 2 3]))) + (is (= "" (s/join \, []))) + (is (= "1 and-a 2 and-a 3" (s/join " and-a " [1 2 3])))) + +(deftest t-chop + (is (= "fo" (s/chop "foo"))) + (is (= "") (s/chop "f")) + (is (= "") (s/chop ""))) + +(deftest t-chomp + (is (= "foo" (s/chomp "foo\n"))) + (is (= "foo" (s/chomp "foo\r\n"))) + (is (= "foo" (s/chomp "foo"))) + (is (= "" (s/chomp "")))) + +(deftest t-swap-case + (is (= "fOO!bAR" (s/swap-case "Foo!Bar"))) + (is (= "" (s/swap-case "")))) + +(deftest t-capitalize + (is (= "Foobar" (s/capitalize "foobar"))) + (is (= "Foobar" (s/capitalize "FOOBAR")))) + +(deftest t-ltrim + (is (= "foo " (s/ltrim " foo "))) + (is (= "" (s/ltrim " ")))) + +(deftest t-rtrim + (is (= " foo" (s/rtrim " foo "))) + (is (= "" (s/rtrim " ")))) + +(deftest t-split-lines + (is (= (list "one" "two" "three") + (s/split-lines "one\ntwo\r\nthree"))) + (is (= (list "foo") (s/split-lines "foo")))) + +(deftest t-upper-case + (is (= "FOOBAR" (s/upper-case "Foobar")))) + +(deftest t-lower-case + (is (= "foobar" (s/lower-case "FooBar")))) + +(deftest t-trim + (is (= "foo" (s/trim " foo \r\n")))) + +(deftest t-substring + (is (s/substring? "foo" "foobar")) + (is (not (s/substring? "baz" "foobar")))) + +(deftest t-get + (is (= \o (s/get "foo" 1)))) + -- cgit v1.2.3-18-g5258