diff options
author | scgilardi <scgilardi@gmail.com> | 2009-03-01 15:26:15 +0000 |
---|---|---|
committer | scgilardi <scgilardi@gmail.com> | 2009-03-01 15:26:15 +0000 |
commit | 8ce94fbc65dd838d3fdf12046b7db29c4ab5ccb7 (patch) | |
tree | e308100745c2f49f9ed6539af149d54b47b96bea /src/clojure/contrib/math/tests.clj | |
parent | d404530419fdb1f5b86cf7587305533d50bf8b5a (diff) |
fix issue 30: add lcm function to clojure.contrib.math (with tests) from gnuvince
Diffstat (limited to 'src/clojure/contrib/math/tests.clj')
-rw-r--r-- | src/clojure/contrib/math/tests.clj | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/src/clojure/contrib/math/tests.clj b/src/clojure/contrib/math/tests.clj index 19304924..64a77cfb 100644 --- a/src/clojure/contrib/math/tests.clj +++ b/src/clojure/contrib/math/tests.clj @@ -30,7 +30,28 @@ (are (= _1 _2)
(gcd 4 3) 1
(gcd 24 12) 12
- (gcd 24 27) 3))
+ (gcd 24 27) 3
+ (gcd 1 0) 1
+ (gcd 0 1) 1
+ (gcd 0 0) 0)
+ (is (thrown? IllegalArgumentException (gcd nil 0)))
+ (is (thrown? IllegalArgumentException (gcd 0 nil)))
+ (is (thrown? IllegalArgumentException (gcd 7.0 0))))
+
+(deftest test-lcm
+ (are (= _1 _2)
+ (lcm 2 3) 6
+ (lcm 3 2) 6
+ (lcm -2 3) 6
+ (lcm 2 -3) 6
+ (lcm -2 -3) 6
+ (lcm 4 10) 20
+ (lcm 1 0) 0
+ (lcm 0 1) 0
+ (lcm 0 0))
+ (is (thrown? IllegalArgumentException (lcm nil 0)))
+ (is (thrown? IllegalArgumentException (lcm 0 nil)))
+ (is (thrown? IllegalArgumentException (lcm 7.0 0))))
(deftest test-floor
(are (= _1 _2)
|