comparison src/clojure/contrib/test_contrib/test_greatest_least.clj @ 10:ef7dbbd6452c

added clojure source goodness
author Robert McIntyre <rlm@mit.edu>
date Sat, 21 Aug 2010 06:25:44 -0400
parents
children
comparison
equal deleted inserted replaced
9:35cf337adfcf 10:ef7dbbd6452c
1 (ns clojure.contrib.test-greatest-least
2 (:use clojure.contrib.greatest-least
3 [clojure.test :only (is deftest run-tests)]))
4
5 (deftest test-greatest
6 (is (nil? (greatest)) "greatest with no arguments is nil")
7 (is (= 1 (greatest 1)))
8 (is (= 2 (greatest 1 2)))
9 (is (= 2 (greatest 2 1)))
10 (is (= "b" (greatest "aa" "b"))))
11
12 (deftest test-greatest-by
13 (is (nil? (greatest-by identity)) "greatest-by with no arguments is nil")
14 (is (= "" (greatest-by count "")))
15 (is (= "a" (greatest-by count "a" "")))
16 (is (= "a" (greatest-by count "" "a")))
17 (is (= "aa" (greatest-by count "aa" "b"))))
18
19 (deftest test-least
20 (is (nil? (least)) "least with no arguments is nil")
21 (is (= 1 (least 1)))
22 (is (= 1 (least 1 2)))
23 (is (= 1 (least 2 1)))
24 (is (= "aa" (least "aa" "b"))))
25
26 (deftest test-least-by
27 (is (nil? (least-by identity)) "least-by with no arguments is nil")
28 (is (= "" (least-by count "")))
29 (is (= "" (least-by count "a" "")))
30 (is (= "" (least-by count "" "a")))
31 (is (= "b" (least-by count "aa" "b"))))
32
33 (deftest test-all-greatest
34 (is (nil? (all-greatest)) "all-greatest with no arguments is nil")
35 (is (= (list 1) (all-greatest 1)))
36 (is (= (list 1 1) (all-greatest 1 1)))
37 (is (= (list 2) (all-greatest 2 1 1)))
38 (is (= (list 2) (all-greatest 1 2 1)))
39 (is (= (list 2) (all-greatest 1 1 2)))
40 (is (= (list :c) (all-greatest :b :c :a))))
41
42 (deftest test-all-greatest-by
43 (is (nil? (all-greatest-by identity)) "all-greatest-by with no arguments is nil")
44 (is (= (list "a")) (all-greatest-by count "a"))
45 (is (= (list "a" "a")) (all-greatest-by count "a" "a"))
46 (is (= (list "aa")) (all-greatest-by count "aa" "b"))
47 (is (= (list "aa")) (all-greatest-by count "b" "aa" "c"))
48 (is (= (list "cc" "aa")) (all-greatest-by count "aa" "b" "cc")))
49
50 (deftest test-all-least
51 (is (nil? (all-least)) "all-least with no arguments is nil")
52 (is (= (list 1) (all-least 1)))
53 (is (= (list 1 1) (all-least 1 1)))
54 (is (= (list 1 1) (all-least 2 1 1)))
55 (is (= (list 1 1) (all-least 1 2 1)))
56 (is (= (list 1 1) (all-least 1 1 2)))
57 (is (= (list :a) (all-least :b :c :a))))
58
59 (deftest test-all-least-by
60 (is (nil? (all-least-by identity)) "all-least-by with no arguments is nil")
61 (is (= (list "a")) (all-least-by count "a"))
62 (is (= (list "a" "a")) (all-least-by count "a" "a"))
63 (is (= (list "b")) (all-least-by count "aa" "b"))
64 (is (= (list "c" "b")) (all-least-by count "b" "aa" "c"))
65 (is (= (list "b")) (all-least-by count "aa" "b" "cc")))