blob: 20f419af3e0d8a8e071ec37bc302bd10bd7dc853 (
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
|
package au.id.zancanaro;
import au.id.zancanaro.annotations.DataSource;
import au.id.zancanaro.annotations.Property;
import org.junit.runner.RunWith;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import static au.id.zancanaro.Generators.integer;
import static au.id.zancanaro.Generators.listOf;
import static org.junit.Assert.assertEquals;
@RunWith(Properties.class)
public class SimpleListOperationsTest {
@DataSource
public static Generator<List<Integer>> listOfIntegers = listOf(integer());
@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);
assertEquals(left, right);
}
@Property(maxSize = 10000, runs = 10000)
public void reverseIsItsOwnInverse(List<Integer> list) {
List<Integer> reversed = new ArrayList<>(list);
Collections.reverse(reversed);
Collections.reverse(reversed);
assertEquals(list, reversed);
}
}
|