Permalink
Browse files

Extracted some basic tests from the usage comments.

  • Loading branch information...
1 parent ae24ee2 commit 4c6fc87c3d18f536042ef0edb4cf9fde4a79bd02 @seancorfield seancorfield committed Sep 12, 2011
Showing with 27 additions and 0 deletions.
  1. +27 −0 src/test/clojure/clojure/math/test_combinatorics.clj
@@ -0,0 +1,27 @@
+(ns clojure.math.test-combinatorics
+ (:use clojure.test
+ clojure.math.combinatorics))
+
+(deftest test-combinations
+ (are [x y] (= x y)
+ (combinations [1 2 3] 2) '((1 2) (1 3) (2 3))))
+
+(deftest test-subsets
+ (are [x y] (= x y)
+ (subsets [1 2 3]) '(() (1) (2) (3) (1 2) (1 3) (2 3) (1 2 3))))
+
+(deftest test-cartesian-product
+ (are [x y] (= x y)
+ (cartesian-product [1 2] [3 4]) '((1 3) (1 4) (2 3) (2 4))))
+
+(deftest test-selections
+ (are [x y] (= x y)
+ (selections [1 2] 3) '((1 1 1) (1 1 2) (1 2 1) (1 2 2) (2 1 1) (2 1 2) (2 2 1) (2 2 2))))
+
+(deftest test-permutations
+ (are [x y] (= x y)
+ (permutations [1 2 3]) '((1 2 3) (1 3 2) (2 1 3) (2 3 1) (3 1 2) (3 2 1))))
+
+(deftest tes-lex-permutations
+ (are [x y] (= x y)
+ (lex-permutations [1 1 2]) '([1 1 2] [1 2 1] [2 1 1])))

0 comments on commit 4c6fc87

Please sign in to comment.