From 7e1182355d54f0dc8461ce7df7c4aca8c40d2a92 Mon Sep 17 00:00:00 2001 From: Carlo Zancanaro Date: Mon, 1 Jun 2015 00:25:19 +1000 Subject: Just some rearranging, renaming and clean-up --- .../au/id/zancanaro/SimpleListOperationsTest.java | 43 ++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 src/test/java/au/id/zancanaro/SimpleListOperationsTest.java (limited to 'src/test/java/au/id/zancanaro/SimpleListOperationsTest.java') diff --git a/src/test/java/au/id/zancanaro/SimpleListOperationsTest.java b/src/test/java/au/id/zancanaro/SimpleListOperationsTest.java new file mode 100644 index 0000000..2ff44e7 --- /dev/null +++ b/src/test/java/au/id/zancanaro/SimpleListOperationsTest.java @@ -0,0 +1,43 @@ +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); + } +} -- cgit v1.2.3