I have a function I want to try out test.check on. But I'm having trouble 
grokking how to write the tests.
Basically the function checks if a vector value in a hash-map has at least 
2 elements.

(defn valid-vector?
  [d]
  (>= 2 (count (:vec d))))


and in my tests (I'm using test.chuck 
<https://github.com/gfredericks/test.chuck>)

(def gen-data
  (gen/hash-map :v (gen/vector gen/string)))

(deftest valid-vector-test
  (checking "data with at least 2 elements in :vec" 100 [d gen-data]
    ;; what to do here?
  ))

I'm confused on how I should write the body of the test. My first thought 
is to do something like:

(checking "data with at least 2 elements in :vec" 100 [d gen-data]
  (if (>= 2 (count (:vec d)))
    (is (true? (valid-vector d)))
    (is (false? (valid-vector d)))))

But that means I just re-wrote my function definition in the `if` 
condition. Is there a better way to test my function? Or does test.check 
just not a good fit for it?

Thanks.

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to