Hi John, since it's a simple predicate, we can test what cases will result 
true, and what false. E.g. :

(is (false (valid-vector? []))
(is (false (valid-vector? [:a]))
(is (false (valid-vector? [1]))
(is (true (valid-vector? [:a 1]))

Practically, I do feel it's a bit unnecessary to use test.check here. Though, 
you might find it helpful, say, to generate vector of different kinds to test!?



—
Sent from Mailbox

On Fri, Mar 27, 2015 at 3:14 PM, John Louis Del Rosario <joh...@gmail.com>
wrote:

> 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.

-- 
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