Skip to content

Commit

Permalink
#364 test queue count
Browse files Browse the repository at this point in the history
Signed-off-by: Stuart Halloway <stu@thinkrelevance.com>
  • Loading branch information
stuarthalloway committed Oct 15, 2010
1 parent 6c4961d commit 11aed89
Showing 1 changed file with 39 additions and 34 deletions.
73 changes: 39 additions & 34 deletions test/clojure/test_clojure/data_structures.clj
Expand Up @@ -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)
Expand Down

0 comments on commit 11aed89

Please sign in to comment.