package au.id.zancanaro; 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 { @SuppressWarnings("unused") public static Generator integers = integer(); @SuppressWarnings("unused") public static Generator> listOfIntegers = listOf(integer()); @Property(maxSize = 10000, runs = 10000) public void sortingIsIdempotent(List list) { List left = new ArrayList<>(list); Collections.sort(left); List right = new ArrayList<>(list); Collections.sort(right); Collections.sort(right); assertEquals(left, right); } @Property(maxSize = 10000, runs = 10000) public void reverseIsItsOwnInverse(List list) { List reversed = new ArrayList<>(list); Collections.reverse(reversed); Collections.reverse(reversed); assertEquals(list, reversed); } }