diff 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
line wrap: on
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/clojure/contrib/test_contrib/test_greatest_least.clj	Sat Aug 21 06:25:44 2010 -0400
     1.3 @@ -0,0 +1,65 @@
     1.4 +(ns clojure.contrib.test-greatest-least
     1.5 +  (:use clojure.contrib.greatest-least
     1.6 +        [clojure.test :only (is deftest run-tests)]))
     1.7 +
     1.8 +(deftest test-greatest
     1.9 +  (is (nil? (greatest)) "greatest with no arguments is nil")
    1.10 +  (is (= 1 (greatest 1)))
    1.11 +  (is (= 2 (greatest 1 2)))
    1.12 +  (is (= 2 (greatest 2 1)))
    1.13 +  (is (= "b" (greatest "aa" "b"))))
    1.14 +
    1.15 +(deftest test-greatest-by
    1.16 +  (is (nil? (greatest-by identity)) "greatest-by with no arguments is nil")
    1.17 +  (is (= "" (greatest-by count "")))
    1.18 +  (is (= "a" (greatest-by count "a" "")))
    1.19 +  (is (= "a" (greatest-by count "" "a")))
    1.20 +  (is (= "aa" (greatest-by count "aa" "b"))))
    1.21 +
    1.22 +(deftest test-least
    1.23 +  (is (nil? (least)) "least with no arguments is nil")
    1.24 +  (is (= 1 (least 1)))
    1.25 +  (is (= 1 (least 1 2)))
    1.26 +  (is (= 1 (least 2 1)))
    1.27 +  (is (= "aa" (least "aa" "b"))))
    1.28 +
    1.29 +(deftest test-least-by
    1.30 +  (is (nil? (least-by identity)) "least-by with no arguments is nil")
    1.31 +  (is (= "" (least-by count "")))
    1.32 +  (is (= "" (least-by count "a" "")))
    1.33 +  (is (= "" (least-by count "" "a")))
    1.34 +  (is (= "b" (least-by count "aa" "b"))))
    1.35 +
    1.36 +(deftest test-all-greatest
    1.37 +  (is (nil? (all-greatest)) "all-greatest with no arguments is nil")
    1.38 +  (is (= (list 1) (all-greatest 1)))
    1.39 +  (is (= (list 1 1) (all-greatest 1 1)))
    1.40 +  (is (= (list 2) (all-greatest 2 1 1)))
    1.41 +  (is (= (list 2) (all-greatest 1 2 1)))
    1.42 +  (is (= (list 2) (all-greatest 1 1 2)))
    1.43 +  (is (= (list :c) (all-greatest :b :c :a))))
    1.44 +
    1.45 +(deftest test-all-greatest-by
    1.46 +  (is (nil? (all-greatest-by identity)) "all-greatest-by with no arguments is nil")
    1.47 +  (is (= (list "a")) (all-greatest-by count "a"))
    1.48 +  (is (= (list "a" "a")) (all-greatest-by count "a" "a"))
    1.49 +  (is (= (list "aa")) (all-greatest-by count "aa" "b"))
    1.50 +  (is (= (list "aa")) (all-greatest-by count "b" "aa" "c"))
    1.51 +  (is (= (list "cc" "aa")) (all-greatest-by count "aa" "b" "cc")))
    1.52 +
    1.53 +(deftest test-all-least
    1.54 +  (is (nil? (all-least)) "all-least with no arguments is nil")
    1.55 +  (is (= (list 1) (all-least 1)))
    1.56 +  (is (= (list 1 1) (all-least 1 1)))
    1.57 +  (is (= (list 1 1) (all-least 2 1 1)))
    1.58 +  (is (= (list 1 1) (all-least 1 2 1)))
    1.59 +  (is (= (list 1 1) (all-least 1 1 2)))
    1.60 +  (is (= (list :a) (all-least :b :c :a))))
    1.61 +
    1.62 +(deftest test-all-least-by
    1.63 +  (is (nil? (all-least-by identity)) "all-least-by with no arguments is nil")
    1.64 +  (is (= (list "a")) (all-least-by count "a"))
    1.65 +  (is (= (list "a" "a")) (all-least-by count "a" "a"))
    1.66 +  (is (= (list "b")) (all-least-by count "aa" "b"))
    1.67 +  (is (= (list "c" "b")) (all-least-by count "b" "aa" "c"))
    1.68 +  (is (= (list "b")) (all-least-by count "aa" "b" "cc")))