File tree Expand file tree Collapse file tree 2 files changed +74
-0
lines changed Expand file tree Collapse file tree 2 files changed +74
-0
lines changed Original file line number Diff line number Diff line change
1
+ (ns clojure.core-test.max
2
+ (:require [clojure.test :as t :refer [deftest testing is are]]))
3
+
4
+ (deftest test-max
5
+ (are [expected x y] (= expected (max x y) (max y x))
6
+ 2 1 2
7
+ 2N 1N 2N
8
+ 2 1N 2
9
+ 2N 1 2N
10
+ 2.0 1.0 2.0
11
+ 2.0 1 2.0
12
+ 2 1.0 2
13
+ 1 1/2 1
14
+ ##Inf 1 ##Inf
15
+ 1 1 ##-Inf
16
+ ##Inf ##-Inf ##Inf )
17
+
18
+ ; ; Single arg just returns argument
19
+ (is (= 1 (max 1 )))
20
+ (is (= 2 (max 2 )))
21
+ (is (= " x" (max " x" ))) ; doesn't check single arg for Number
22
+
23
+ ; ; Multi-arg
24
+ (is (= 5 (max 1 2 3 4 5 )))
25
+ (is (= 5 (max 5 4 3 2 1 )))
26
+ (is (= 5 (max 1 2 3 4 5 ##-Inf )))
27
+ (is (= ##Inf (max 1 2 3 4 5 ##Inf )))
28
+
29
+ (is (NaN? (max ##NaN 1 )))
30
+ (is (NaN? (max 1 ##NaN )))
31
+ (is (NaN? (max 1 2 3 4 ##NaN )))
32
+ (is (NaN? (max ##-Inf ##NaN ##Inf )))
33
+ (is (NaN? (max ##NaN )))
34
+
35
+ (is (thrown? Exception (max " x" " y" )))
36
+ (is (thrown? Exception (max nil 1 )))
37
+ (is (thrown? Exception (max 1 nil ))))
Original file line number Diff line number Diff line change
1
+ (ns clojure.core-test.min
2
+ (:require [clojure.test :as t :refer [deftest testing is are]]))
3
+
4
+ (deftest test-min
5
+ (are [expected x y] (= expected (min x y) (min y x))
6
+ 1 1 2
7
+ 1N 1N 2N
8
+ 1N 1N 2
9
+ 1 1 2N
10
+ 1.0 1.0 2.0
11
+ 1 1 2.0
12
+ 1.0 1.0 2
13
+ 1/2 1/2 1
14
+ 1 1 ##Inf
15
+ ##-Inf 1 ##-Inf
16
+ ##-Inf ##-Inf ##Inf )
17
+
18
+ ; ; Single arg just returns argument
19
+ (is (= 1 (min 1 )))
20
+ (is (= 2 (min 2 )))
21
+ (is (= " x" (min " x" ))) ; doesn't check single arg for Number
22
+
23
+ ; ; Multi-arg
24
+ (is (= 1 (min 1 2 3 4 5 )))
25
+ (is (= 1 (min 5 4 3 2 1 )))
26
+ (is (= ##-Inf (min 1 2 3 4 5 ##-Inf )))
27
+ (is (= 1 (min 1 2 3 4 5 ##Inf )))
28
+
29
+ (is (NaN? (min ##NaN 1 )))
30
+ (is (NaN? (min 1 ##NaN )))
31
+ (is (NaN? (min 1 2 3 4 ##NaN )))
32
+ (is (NaN? (min ##-Inf ##NaN ##Inf )))
33
+ (is (NaN? (min ##NaN )))
34
+
35
+ (is (thrown? Exception (min " x" " y" )))
36
+ (is (thrown? Exception (min nil 1 )))
37
+ (is (thrown? Exception (min 1 nil ))))
You can’t perform that action at this time.
0 commit comments