rlm@10
|
1 (ns clojure.contrib.test-greatest-least
|
rlm@10
|
2 (:use clojure.contrib.greatest-least
|
rlm@10
|
3 [clojure.test :only (is deftest run-tests)]))
|
rlm@10
|
4
|
rlm@10
|
5 (deftest test-greatest
|
rlm@10
|
6 (is (nil? (greatest)) "greatest with no arguments is nil")
|
rlm@10
|
7 (is (= 1 (greatest 1)))
|
rlm@10
|
8 (is (= 2 (greatest 1 2)))
|
rlm@10
|
9 (is (= 2 (greatest 2 1)))
|
rlm@10
|
10 (is (= "b" (greatest "aa" "b"))))
|
rlm@10
|
11
|
rlm@10
|
12 (deftest test-greatest-by
|
rlm@10
|
13 (is (nil? (greatest-by identity)) "greatest-by with no arguments is nil")
|
rlm@10
|
14 (is (= "" (greatest-by count "")))
|
rlm@10
|
15 (is (= "a" (greatest-by count "a" "")))
|
rlm@10
|
16 (is (= "a" (greatest-by count "" "a")))
|
rlm@10
|
17 (is (= "aa" (greatest-by count "aa" "b"))))
|
rlm@10
|
18
|
rlm@10
|
19 (deftest test-least
|
rlm@10
|
20 (is (nil? (least)) "least with no arguments is nil")
|
rlm@10
|
21 (is (= 1 (least 1)))
|
rlm@10
|
22 (is (= 1 (least 1 2)))
|
rlm@10
|
23 (is (= 1 (least 2 1)))
|
rlm@10
|
24 (is (= "aa" (least "aa" "b"))))
|
rlm@10
|
25
|
rlm@10
|
26 (deftest test-least-by
|
rlm@10
|
27 (is (nil? (least-by identity)) "least-by with no arguments is nil")
|
rlm@10
|
28 (is (= "" (least-by count "")))
|
rlm@10
|
29 (is (= "" (least-by count "a" "")))
|
rlm@10
|
30 (is (= "" (least-by count "" "a")))
|
rlm@10
|
31 (is (= "b" (least-by count "aa" "b"))))
|
rlm@10
|
32
|
rlm@10
|
33 (deftest test-all-greatest
|
rlm@10
|
34 (is (nil? (all-greatest)) "all-greatest with no arguments is nil")
|
rlm@10
|
35 (is (= (list 1) (all-greatest 1)))
|
rlm@10
|
36 (is (= (list 1 1) (all-greatest 1 1)))
|
rlm@10
|
37 (is (= (list 2) (all-greatest 2 1 1)))
|
rlm@10
|
38 (is (= (list 2) (all-greatest 1 2 1)))
|
rlm@10
|
39 (is (= (list 2) (all-greatest 1 1 2)))
|
rlm@10
|
40 (is (= (list :c) (all-greatest :b :c :a))))
|
rlm@10
|
41
|
rlm@10
|
42 (deftest test-all-greatest-by
|
rlm@10
|
43 (is (nil? (all-greatest-by identity)) "all-greatest-by with no arguments is nil")
|
rlm@10
|
44 (is (= (list "a")) (all-greatest-by count "a"))
|
rlm@10
|
45 (is (= (list "a" "a")) (all-greatest-by count "a" "a"))
|
rlm@10
|
46 (is (= (list "aa")) (all-greatest-by count "aa" "b"))
|
rlm@10
|
47 (is (= (list "aa")) (all-greatest-by count "b" "aa" "c"))
|
rlm@10
|
48 (is (= (list "cc" "aa")) (all-greatest-by count "aa" "b" "cc")))
|
rlm@10
|
49
|
rlm@10
|
50 (deftest test-all-least
|
rlm@10
|
51 (is (nil? (all-least)) "all-least with no arguments is nil")
|
rlm@10
|
52 (is (= (list 1) (all-least 1)))
|
rlm@10
|
53 (is (= (list 1 1) (all-least 1 1)))
|
rlm@10
|
54 (is (= (list 1 1) (all-least 2 1 1)))
|
rlm@10
|
55 (is (= (list 1 1) (all-least 1 2 1)))
|
rlm@10
|
56 (is (= (list 1 1) (all-least 1 1 2)))
|
rlm@10
|
57 (is (= (list :a) (all-least :b :c :a))))
|
rlm@10
|
58
|
rlm@10
|
59 (deftest test-all-least-by
|
rlm@10
|
60 (is (nil? (all-least-by identity)) "all-least-by with no arguments is nil")
|
rlm@10
|
61 (is (= (list "a")) (all-least-by count "a"))
|
rlm@10
|
62 (is (= (list "a" "a")) (all-least-by count "a" "a"))
|
rlm@10
|
63 (is (= (list "b")) (all-least-by count "aa" "b"))
|
rlm@10
|
64 (is (= (list "c" "b")) (all-least-by count "b" "aa" "c"))
|
rlm@10
|
65 (is (= (list "b")) (all-least-by count "aa" "b" "cc")))
|