
On Tue, Oct 06, 2015 at 10:24:03PM +0200, Roelof Wobben wrote:
Hello,
I have written a function to test if three numbers are the same.
Now I want to test my functions by using quickCheck.
So I thought to test first if all three are the same.
but how can I tell quickcheck that all numbers are the same.
Easy, just generate a single number. :) Make it correct by construction. prop_allSame x = yourFunc x x x == True
and second question : hwo do the test likeif two numbers are the same.
Now the hard part is not generating two numbers that are the same, but generating two *different* numbers. To do that you may need to create a custom generator. unequalPair = do x <- arbitrary y <- arbitrary `suchThat` y /= x return (x,y) Now you can use that generator: prop_twoSame = forAll unequalPair $ \(x,y) -> yourFunc x x y == False -- But you might want to test all permutations!