diff options
Diffstat (limited to 'src/test/java/au/id')
| -rw-r--r-- | src/test/java/au/id/zancanaro/PropertyTests.java | 43 | 
1 files changed, 33 insertions, 10 deletions
| diff --git a/src/test/java/au/id/zancanaro/PropertyTests.java b/src/test/java/au/id/zancanaro/PropertyTests.java index 374a974..dd595e1 100644 --- a/src/test/java/au/id/zancanaro/PropertyTests.java +++ b/src/test/java/au/id/zancanaro/PropertyTests.java @@ -1,35 +1,58 @@  package au.id.zancanaro;  import au.id.zancanaro.annotations.Property; +import au.id.zancanaro.annotations.Seed; +import org.hamcrest.CoreMatchers;  import org.junit.*;  import org.junit.experimental.theories.DataPoint; +import org.junit.matchers.JUnitMatchers;  import org.junit.runner.RunWith; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +  @RunWith(PropertyTestRunner.class)  public class PropertyTests {      public static Generator<Integer> gen = Generators.integer(); +    public static Generator<List<Integer>> list = Generators.listOf(Generators.integer()); -    @Test -    public void testblah() throws Exception { -        Assert.assertEquals(10, 11); - -    } - +    @Ignore      @Property      public void aIsNotOdd(int a, int b) { -        Assume.assumeFalse(a % 2 == 1);          Assert.assertFalse(a % 2 == 1);      } +    @Ignore      @Property      public void aIsNotLessThanB(int a, int b) { -        Assume.assumeFalse(a < b);          Assert.assertFalse(a < b);      } +    @Ignore      @Property      public void aPlusBLessThanOneHundred(int a, int b) { -        Assert.assertTrue("a plus b is five", a + b == 5); -        Assert.assertEquals(a + b, 5); +        Assert.assertTrue(a + b < 100); +    } + +    @Property +    public void sortingIsIdempotent(List<Integer> list) { +        List<Integer> left = new ArrayList<>(list); +        Collections.sort(left); + +        List<Integer> right = new ArrayList<>(list); +        Collections.sort(right); +        Collections.sort(right); + +        Assert.assertEquals(left, right); +    } + +    @Property +    public void reverseIsItsOwnInverse(List<Integer> list) { +        List<Integer> reversed = new ArrayList<>(list); +        Collections.reverse(reversed); +        Collections.reverse(reversed); + +        Assert.assertEquals(list, reversed);      }  } | 
