blob: dd595e1faf42f94f4688c56446e7f518ff1c22f5 (
about) (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
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());
@Ignore
@Property
public void aIsNotOdd(int a, int b) {
Assert.assertFalse(a % 2 == 1);
}
@Ignore
@Property
public void aIsNotLessThanB(int a, int b) {
Assert.assertFalse(a < b);
}
@Ignore
@Property
public void aPlusBLessThanOneHundred(int a, int b) {
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);
}
}
|