rlm@10: (ns clojure.contrib.test-greatest-least rlm@10: (:use clojure.contrib.greatest-least rlm@10: [clojure.test :only (is deftest run-tests)])) rlm@10: rlm@10: (deftest test-greatest rlm@10: (is (nil? (greatest)) "greatest with no arguments is nil") rlm@10: (is (= 1 (greatest 1))) rlm@10: (is (= 2 (greatest 1 2))) rlm@10: (is (= 2 (greatest 2 1))) rlm@10: (is (= "b" (greatest "aa" "b")))) rlm@10: rlm@10: (deftest test-greatest-by rlm@10: (is (nil? (greatest-by identity)) "greatest-by with no arguments is nil") rlm@10: (is (= "" (greatest-by count ""))) rlm@10: (is (= "a" (greatest-by count "a" ""))) rlm@10: (is (= "a" (greatest-by count "" "a"))) rlm@10: (is (= "aa" (greatest-by count "aa" "b")))) rlm@10: rlm@10: (deftest test-least rlm@10: (is (nil? (least)) "least with no arguments is nil") rlm@10: (is (= 1 (least 1))) rlm@10: (is (= 1 (least 1 2))) rlm@10: (is (= 1 (least 2 1))) rlm@10: (is (= "aa" (least "aa" "b")))) rlm@10: rlm@10: (deftest test-least-by rlm@10: (is (nil? (least-by identity)) "least-by with no arguments is nil") rlm@10: (is (= "" (least-by count ""))) rlm@10: (is (= "" (least-by count "a" ""))) rlm@10: (is (= "" (least-by count "" "a"))) rlm@10: (is (= "b" (least-by count "aa" "b")))) rlm@10: rlm@10: (deftest test-all-greatest rlm@10: (is (nil? (all-greatest)) "all-greatest with no arguments is nil") rlm@10: (is (= (list 1) (all-greatest 1))) rlm@10: (is (= (list 1 1) (all-greatest 1 1))) rlm@10: (is (= (list 2) (all-greatest 2 1 1))) rlm@10: (is (= (list 2) (all-greatest 1 2 1))) rlm@10: (is (= (list 2) (all-greatest 1 1 2))) rlm@10: (is (= (list :c) (all-greatest :b :c :a)))) rlm@10: rlm@10: (deftest test-all-greatest-by rlm@10: (is (nil? (all-greatest-by identity)) "all-greatest-by with no arguments is nil") rlm@10: (is (= (list "a")) (all-greatest-by count "a")) rlm@10: (is (= (list "a" "a")) (all-greatest-by count "a" "a")) rlm@10: (is (= (list "aa")) (all-greatest-by count "aa" "b")) rlm@10: (is (= (list "aa")) (all-greatest-by count "b" "aa" "c")) rlm@10: (is (= (list "cc" "aa")) (all-greatest-by count "aa" "b" "cc"))) rlm@10: rlm@10: (deftest test-all-least rlm@10: (is (nil? (all-least)) "all-least with no arguments is nil") rlm@10: (is (= (list 1) (all-least 1))) rlm@10: (is (= (list 1 1) (all-least 1 1))) rlm@10: (is (= (list 1 1) (all-least 2 1 1))) rlm@10: (is (= (list 1 1) (all-least 1 2 1))) rlm@10: (is (= (list 1 1) (all-least 1 1 2))) rlm@10: (is (= (list :a) (all-least :b :c :a)))) rlm@10: rlm@10: (deftest test-all-least-by rlm@10: (is (nil? (all-least-by identity)) "all-least-by with no arguments is nil") rlm@10: (is (= (list "a")) (all-least-by count "a")) rlm@10: (is (= (list "a" "a")) (all-least-by count "a" "a")) rlm@10: (is (= (list "b")) (all-least-by count "aa" "b")) rlm@10: (is (= (list "c" "b")) (all-least-by count "b" "aa" "c")) rlm@10: (is (= (list "b")) (all-least-by count "aa" "b" "cc")))