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 --- src/test/java/au/id/zancanaro/PropertyTests.java | 58 ---------------------- src/test/java/au/id/zancanaro/SimpleGenerator.java | 19 ------- .../au/id/zancanaro/SimpleListOperationsTest.java | 43 ++++++++++++++++ src/test/java/au/id/zancanaro/TheoriesTest.java | 22 -------- 4 files changed, 43 insertions(+), 99 deletions(-) delete mode 100644 src/test/java/au/id/zancanaro/PropertyTests.java delete mode 100644 src/test/java/au/id/zancanaro/SimpleGenerator.java create mode 100644 src/test/java/au/id/zancanaro/SimpleListOperationsTest.java delete mode 100644 src/test/java/au/id/zancanaro/TheoriesTest.java (limited to 'src/test') diff --git a/src/test/java/au/id/zancanaro/PropertyTests.java b/src/test/java/au/id/zancanaro/PropertyTests.java deleted file mode 100644 index dd595e1..0000000 --- a/src/test/java/au/id/zancanaro/PropertyTests.java +++ /dev/null @@ -1,58 +0,0 @@ -package au.id.zancanaro; - -import au.id.zancanaro.annotations.Property; -import au.id.zancanaro.annotations.Seed; -import org.hamcrest.CoreMatchers; -import org.junit.*; -import org.junit.experimental.theories.DataPoint; -import org.junit.matchers.JUnitMatchers; -import org.junit.runner.RunWith; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; - -@RunWith(PropertyTestRunner.class) -public class PropertyTests { - public static Generator gen = Generators.integer(); - public static Generator> list = Generators.listOf(Generators.integer()); - - @Ignore - @Property - public void aIsNotOdd(int a, int b) { - Assert.assertFalse(a % 2 == 1); - } - - @Ignore - @Property - public void aIsNotLessThanB(int a, int b) { - Assert.assertFalse(a < b); - } - - @Ignore - @Property - public void aPlusBLessThanOneHundred(int a, int b) { - Assert.assertTrue(a + b < 100); - } - - @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); - - Assert.assertEquals(left, right); - } - - @Property - public void reverseIsItsOwnInverse(List list) { - List reversed = new ArrayList<>(list); - Collections.reverse(reversed); - Collections.reverse(reversed); - - Assert.assertEquals(list, reversed); - } -} diff --git a/src/test/java/au/id/zancanaro/SimpleGenerator.java b/src/test/java/au/id/zancanaro/SimpleGenerator.java deleted file mode 100644 index 1b1d570..0000000 --- a/src/test/java/au/id/zancanaro/SimpleGenerator.java +++ /dev/null @@ -1,19 +0,0 @@ -package au.id.zancanaro; - -import org.junit.Assert; -import org.junit.Test; - -import java.util.Random; - -public class SimpleGenerator { - @Test - public void testSimpleGeneratorFlatmap() throws Exception { - Generator generator = Generator - .pure(10) - .flatMap((value) -> - Generator.pure(value + 10)); - Assert.assertEquals( - (Object) 20, - generator.generate(null, 0).getValue()); - } -} 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); + } +} diff --git a/src/test/java/au/id/zancanaro/TheoriesTest.java b/src/test/java/au/id/zancanaro/TheoriesTest.java deleted file mode 100644 index 7d5071c..0000000 --- a/src/test/java/au/id/zancanaro/TheoriesTest.java +++ /dev/null @@ -1,22 +0,0 @@ -package au.id.zancanaro; - -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.theories.DataPoint; -import org.junit.experimental.theories.Theories; -import org.junit.experimental.theories.Theory; -import org.junit.runner.RunWith; - -@RunWith(Theories.class) -public class TheoriesTest { - @DataPoint - public static String car = "carlo"; - - @DataPoint - public static String car2 = "carlo2"; - - @Theory - public void testName(String str) throws Exception { - Assert.assertEquals(str, car2); - } -} -- cgit v1.2.3