blob: 3cfef374b244e743c36ff3d600b01ad935ce41b2 (
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
|
package au.id.zancanaro.javacheck;
import au.id.zancanaro.javacheck.annotations.Property;
import au.id.zancanaro.javacheck.junit.Properties;
import org.junit.runner.RunWith;
import java.util.ArrayList;
import java.util.List;
import static java.util.Collections.reverse;
import static java.util.Collections.sort;
import static org.junit.Assert.assertEquals;
@RunWith(Properties.class)
public class SimpleListOperationsTest {
@Property
public void sortingIsIdempotent(List<Integer> list) {
List<Integer> left = new ArrayList<>(list);
sort(left);
List<Integer> right = new ArrayList<>(list);
sort(right);
sort(right);
assertEquals(left, right);
}
@Property
public void reverseIsItsOwnInverse(List<String> list) {
List<String> reversed = new ArrayList<>(list);
reverse(reversed);
reverse(reversed);
assertEquals(list, reversed);
}
}
|