diff options
author | Stuart Halloway <stu@thinkrelevance.com> | 2010-10-14 09:35:21 -0400 |
---|---|---|
committer | Stuart Halloway <stu@thinkrelevance.com> | 2010-10-15 07:26:21 -0400 |
commit | 11aed8912e8247629398e0c12484401d6f8ca3ed (patch) | |
tree | 706863ac77990d137b04e8de7620eb906c78f6fa | |
parent | 6c4961d526a7c114736627250ff874703b987bcb (diff) |
#364 test queue count
Signed-off-by: Stuart Halloway <stu@thinkrelevance.com>
-rw-r--r-- | test/clojure/test_clojure/data_structures.clj | 73 |
1 files changed, 39 insertions, 34 deletions
diff --git a/test/clojure/test_clojure/data_structures.clj b/test/clojure/test_clojure/data_structures.clj index a1f5b825..7679b2b6 100644 --- a/test/clojure/test_clojure/data_structures.clj +++ b/test/clojure/test_clojure/data_structures.clj @@ -112,40 +112,45 @@ ;; *** Collections *** (deftest test-count - (are [x y] (= x y) - (count nil) 0 - - (count ()) 0 - (count '(1)) 1 - (count '(1 2 3)) 3 - - (count []) 0 - (count [1]) 1 - (count [1 2 3]) 3 - - (count #{}) 0 - (count #{1}) 1 - (count #{1 2 3}) 3 - - (count {}) 0 - (count {:a 1}) 1 - (count {:a 1 :b 2 :c 3}) 3 - - (count "") 0 - (count "a") 1 - (count "abc") 3 - - (count (into-array [])) 0 - (count (into-array [1])) 1 - (count (into-array [1 2 3])) 3 - - (count (java.util.ArrayList. [])) 0 - (count (java.util.ArrayList. [1])) 1 - (count (java.util.ArrayList. [1 2 3])) 3 - - (count (java.util.HashMap. {})) 0 - (count (java.util.HashMap. {:a 1})) 1 - (count (java.util.HashMap. {:a 1 :b 2 :c 3})) 3 ) + (let [EMPTY clojure.lang.PersistentQueue/EMPTY] + (are [x y] (= (count x) y) + EMPTY 0 + (into EMPTY [:a :b]) 2 + (-> (into EMPTY [:a :b]) pop pop) 0 + + nil 0 + + () 0 + '(1) 1 + '(1 2 3) 3 + + [] 0 + [1] 1 + [1 2 3] 3 + + #{} 0 + #{1} 1 + #{1 2 3} 3 + + {} 0 + {:a 1} 1 + {:a 1 :b 2 :c 3} 3 + + "" 0 + "a" 1 + "abc" 3 + + (into-array []) 0 + (into-array [1]) 1 + (into-array [1 2 3]) 3 + + (java.util.ArrayList. []) 0 + (java.util.ArrayList. [1]) 1 + (java.util.ArrayList. [1 2 3]) 3 + + (java.util.HashMap. {}) 0 + (java.util.HashMap. {:a 1}) 1 + (java.util.HashMap. {:a 1 :b 2 :c 3}) 3 )) ; different types (are [x] (= (count [x]) 1) |