aboutsummaryrefslogtreecommitdiff
path: root/src/clojure/contrib/test_contrib
diff options
context:
space:
mode:
authorChouser <chouser@n01se.net>2009-03-19 20:37:58 +0000
committerChouser <chouser@n01se.net>2009-03-19 20:37:58 +0000
commit3baeb919015c22ace1a42efaf5eaa948963aea93 (patch)
tree5feb0f0032350d1884acbae527463c69007a0aa2 /src/clojure/contrib/test_contrib
parenta31e6f0f9e6b2ecd82bd5e94bb9e3d7926eeb07f (diff)
Add greatest-least, from gnuvince
Diffstat (limited to 'src/clojure/contrib/test_contrib')
-rw-r--r--src/clojure/contrib/test_contrib/greatest_least.clj65
1 files changed, 65 insertions, 0 deletions
diff --git a/src/clojure/contrib/test_contrib/greatest_least.clj b/src/clojure/contrib/test_contrib/greatest_least.clj
new file mode 100644
index 00000000..557c0a3c
--- /dev/null
+++ b/src/clojure/contrib/test_contrib/greatest_least.clj
@@ -0,0 +1,65 @@
+(ns clojure.contrib.test-contrib.greatest-least
+ (:use clojure.contrib.greatest-least
+ [clojure.contrib.test-is :only (is deftest run-tests)]))
+
+(deftest test-greatest
+ (is (nil? (greatest)) "greatest with no arguments is nil")
+ (is (= 1 (greatest 1)))
+ (is (= 2 (greatest 1 2)))
+ (is (= 2 (greatest 2 1)))
+ (is (= "b" (greatest "aa" "b"))))
+
+(deftest test-greatest-by
+ (is (nil? (greatest-by identity)) "greatest-by with no arguments is nil")
+ (is (= "" (greatest-by count "")))
+ (is (= "a" (greatest-by count "a" "")))
+ (is (= "a" (greatest-by count "" "a")))
+ (is (= "aa" (greatest-by count "aa" "b"))))
+
+(deftest test-least
+ (is (nil? (least)) "least with no arguments is nil")
+ (is (= 1 (least 1)))
+ (is (= 1 (least 1 2)))
+ (is (= 1 (least 2 1)))
+ (is (= "aa" (least "aa" "b"))))
+
+(deftest test-least-by
+ (is (nil? (least-by identity)) "least-by with no arguments is nil")
+ (is (= "" (least-by count "")))
+ (is (= "" (least-by count "a" "")))
+ (is (= "" (least-by count "" "a")))
+ (is (= "b" (least-by count "aa" "b"))))
+
+(deftest test-all-greatest
+ (is (nil? (all-greatest)) "all-greatest with no arguments is nil")
+ (is (= (list 1) (all-greatest 1)))
+ (is (= (list 1 1) (all-greatest 1 1)))
+ (is (= (list 2) (all-greatest 2 1 1)))
+ (is (= (list 2) (all-greatest 1 2 1)))
+ (is (= (list 2) (all-greatest 1 1 2)))
+ (is (= (list :c) (all-greatest :b :c :a))))
+
+(deftest test-all-greatest-by
+ (is (nil? (all-greatest-by identity)) "all-greatest-by with no arguments is nil")
+ (is (= (list "a")) (all-greatest-by count "a"))
+ (is (= (list "a" "a")) (all-greatest-by count "a" "a"))
+ (is (= (list "aa")) (all-greatest-by count "aa" "b"))
+ (is (= (list "aa")) (all-greatest-by count "b" "aa" "c"))
+ (is (= (list "cc" "aa")) (all-greatest-by count "aa" "b" "cc")))
+
+(deftest test-all-least
+ (is (nil? (all-least)) "all-least with no arguments is nil")
+ (is (= (list 1) (all-least 1)))
+ (is (= (list 1 1) (all-least 1 1)))
+ (is (= (list 1 1) (all-least 2 1 1)))
+ (is (= (list 1 1) (all-least 1 2 1)))
+ (is (= (list 1 1) (all-least 1 1 2)))
+ (is (= (list :a) (all-least :b :c :a))))
+
+(deftest test-all-least-by
+ (is (nil? (all-least-by identity)) "all-least-by with no arguments is nil")
+ (is (= (list "a")) (all-least-by count "a"))
+ (is (= (list "a" "a")) (all-least-by count "a" "a"))
+ (is (= (list "b")) (all-least-by count "aa" "b"))
+ (is (= (list "c" "b")) (all-least-by count "b" "aa" "c"))
+ (is (= (list "b")) (all-least-by count "aa" "b" "cc")))