Last active
March 7, 2016 22:16
-
-
Save quii/7b8473a388aebef9b91b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func TestAddingZeroMakesNoDifference(t *testing.T) { | |
/* | |
Create an assertion, which is a function that takes N inputs of | |
random data and returns true if the assertion passes. | |
In this case, we're saying take any random integer (x) | |
If you add 0, it should equal x | |
*/ | |
assertion := func(x int) bool { | |
return add(x, 0) == x | |
} | |
// Run the assertion through the quick checker | |
if err := quick.Check(assertion, nil); err != nil { | |
t.Error(err) | |
} | |
} | |
func TestAssociativity(t *testing.T) { | |
assertion := func(x, y, z int) bool { | |
return add(add(x, y), z) == add(add(z, y), x) | |
} | |
if err := quick.Check(assertion, nil); err != nil { | |
t.Error(err) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment