summaryrefslogtreecommitdiff
path: root/src/test/java/au/id
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/java/au/id')
-rw-r--r--src/test/java/au/id/zancanaro/PropertyTests.java58
-rw-r--r--src/test/java/au/id/zancanaro/SimpleGenerator.java19
-rw-r--r--src/test/java/au/id/zancanaro/SimpleListOperationsTest.java43
-rw-r--r--src/test/java/au/id/zancanaro/TheoriesTest.java22
4 files changed, 43 insertions, 99 deletions
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<Integer> gen = Generators.integer();
- public static Generator<List<Integer>> 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<Integer> list) {
- List<Integer> left = new ArrayList<>(list);
- Collections.sort(left);
-
- List<Integer> right = new ArrayList<>(list);
- Collections.sort(right);
- Collections.sort(right);
-
- Assert.assertEquals(left, right);
- }
-
- @Property
- public void reverseIsItsOwnInverse(List<Integer> list) {
- List<Integer> 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<Integer> 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<Integer> integers = integer();
+
+ @SuppressWarnings("unused")
+ public static Generator<List<Integer>> listOfIntegers = listOf(integer());
+
+ @Property(maxSize = 10000, runs = 10000)
+ public void sortingIsIdempotent(List<Integer> list) {
+ List<Integer> left = new ArrayList<>(list);
+ Collections.sort(left);
+
+ List<Integer> right = new ArrayList<>(list);
+ Collections.sort(right);
+ Collections.sort(right);
+
+ assertEquals(left, right);
+ }
+
+ @Property(maxSize = 10000, runs = 10000)
+ public void reverseIsItsOwnInverse(List<Integer> list) {
+ List<Integer> 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);
- }
-}