From 8187f024bae57267af514c5dcb730de09e573e41 Mon Sep 17 00:00:00 2001 From: Carlo Zancanaro Date: Mon, 1 Jun 2015 11:41:16 +1000 Subject: Move packages, make lists shrink in size, generate lists instead of arrays as the 'primitive' operation (issues with generics) --- .../au/id/zancanaro/SimpleListOperationsTest.java | 41 -------------------- .../javacheck/junit/SimpleListOperationsTest.java | 45 ++++++++++++++++++++++ 2 files changed, 45 insertions(+), 41 deletions(-) delete mode 100644 src/test/java/au/id/zancanaro/SimpleListOperationsTest.java create mode 100644 src/test/java/au/id/zancanaro/javacheck/junit/SimpleListOperationsTest.java (limited to 'src/test/java/au') diff --git a/src/test/java/au/id/zancanaro/SimpleListOperationsTest.java b/src/test/java/au/id/zancanaro/SimpleListOperationsTest.java deleted file mode 100644 index 20f419a..0000000 --- a/src/test/java/au/id/zancanaro/SimpleListOperationsTest.java +++ /dev/null @@ -1,41 +0,0 @@ -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> listOfIntegers = listOf(integer()); - - @Property - 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); - } -} diff --git a/src/test/java/au/id/zancanaro/javacheck/junit/SimpleListOperationsTest.java b/src/test/java/au/id/zancanaro/javacheck/junit/SimpleListOperationsTest.java new file mode 100644 index 0000000..8a298be --- /dev/null +++ b/src/test/java/au/id/zancanaro/javacheck/junit/SimpleListOperationsTest.java @@ -0,0 +1,45 @@ +package au.id.zancanaro.javacheck.junit; + +import au.id.zancanaro.javacheck.Generator; +import au.id.zancanaro.javacheck.annotations.DataSource; +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.Collections; +import java.util.List; + +import static au.id.zancanaro.javacheck.Generators.*; +import static org.junit.Assert.assertEquals; + +@RunWith(Properties.class) +public class SimpleListOperationsTest { + + @DataSource + public static Generator> listOfIntegers = listOf(integer()); + + @DataSource + public static Generator> listOfStrings = listOf(stringOf(alphaNumericCharacter())); + + @Property(maxSize = 100, runs = 1000) + 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 = 100, runs = 1000) + public void reverseIsItsOwnInverse(List list) { + List reversed = new ArrayList<>(list); + Collections.reverse(reversed); + Collections.reverse(reversed); + + assertEquals(list, reversed); + } +} -- cgit v1.2.3