Created
April 6, 2020 12:37
-
-
Save ythirion/c342d0369f5e9517bcc10537fdade046 to your computer and use it in GitHub Desktop.
PBT
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
import com.pholser.junit.quickcheck.Property; | |
import com.pholser.junit.quickcheck.runner.JUnitQuickcheck; | |
import org.junit.Assert; | |
import org.junit.runner.RunWith; | |
@RunWith(JUnitQuickcheck.class) | |
public class Addition_properties { | |
@Property | |
public void commutative(int randomX, int randomY) { | |
int result1 = Calculator.add(randomX, randomY); | |
int result2 = Calculator.add(randomY, randomX); | |
Assert.assertEquals(result1, result2); | |
} | |
@Property | |
public void associative(int randomX) { | |
int result1 = Calculator.add(randomX, 1); | |
result1 = Calculator.add(result1, 1); | |
int result2 = Calculator.add(randomX, 2); | |
Assert.assertEquals(result1, result2); | |
} | |
@Property | |
public void identity(int randomX) { | |
int result1 = Calculator.add(randomX, 0); | |
Assert.assertEquals(result1, randomX); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment