diff options
Diffstat (limited to 'src/test/java/au/id/zancanaro/javacheck')
5 files changed, 22 insertions, 22 deletions
diff --git a/src/test/java/au/id/zancanaro/javacheck/ListFunctorRulesTest.java b/src/test/java/au/id/zancanaro/javacheck/ListFunctorRulesTest.java index b757bcd..4100378 100644 --- a/src/test/java/au/id/zancanaro/javacheck/ListFunctorRulesTest.java +++ b/src/test/java/au/id/zancanaro/javacheck/ListFunctorRulesTest.java @@ -9,7 +9,8 @@ import java.util.List; import java.util.function.Function; import java.util.stream.Collectors; -import static au.id.zancanaro.javacheck.Generators.*; +import static au.id.zancanaro.javacheck.Generators.longInteger; +import static au.id.zancanaro.javacheck.Generators.oneOf; import static org.junit.Assert.assertEquals; @RunWith(Properties.class) @@ -19,9 +20,6 @@ public class ListFunctorRulesTest { private final static int maxSize = 1000; @DataSource - public static Generator<List<Long>> listOfIntegers = listOf(longInteger()); - - @DataSource public static Generator<Function<Long, Long>> integerFunction = oneOf( longInteger().map(ListFunctorRulesTest::plusI), diff --git a/src/test/java/au/id/zancanaro/javacheck/SimpleListOperationsTest.java b/src/test/java/au/id/zancanaro/javacheck/SimpleListOperationsTest.java index fcc8baf..3f4d58b 100644 --- a/src/test/java/au/id/zancanaro/javacheck/SimpleListOperationsTest.java +++ b/src/test/java/au/id/zancanaro/javacheck/SimpleListOperationsTest.java @@ -1,6 +1,5 @@ package au.id.zancanaro.javacheck; -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; @@ -8,7 +7,6 @@ import org.junit.runner.RunWith; import java.util.ArrayList; import java.util.List; -import static au.id.zancanaro.javacheck.Generators.*; import static java.util.Collections.reverse; import static java.util.Collections.sort; import static org.junit.Assert.assertEquals; @@ -19,12 +17,6 @@ public class SimpleListOperationsTest { private final static int runs = 1000; private final static int maxSize = 1000; - @DataSource - public static Generator<List<Integer>> listOfIntegers = listOf(integer()); - - @DataSource - public static Generator<List<String>> listOfStrings = listOf(stringOf(alphaNumericCharacter())); - @Property(maxSize = maxSize, runs = runs) public void sortingIsIdempotent(List<Integer> list) { List<Integer> left = new ArrayList<>(list); diff --git a/src/test/java/au/id/zancanaro/javacheck/object/MyObject.java b/src/test/java/au/id/zancanaro/javacheck/object/MyObject.java index ac0c370..824fd8d 100644 --- a/src/test/java/au/id/zancanaro/javacheck/object/MyObject.java +++ b/src/test/java/au/id/zancanaro/javacheck/object/MyObject.java @@ -1,5 +1,13 @@ package au.id.zancanaro.javacheck.object; +import au.id.zancanaro.javacheck.Generator; +import au.id.zancanaro.javacheck.ShrinkTree; + +import java.util.Random; + +import static au.id.zancanaro.javacheck.Generators.asciiCharacter; +import static au.id.zancanaro.javacheck.Generators.stringOf; + public class MyObject { public final String string; public final int value; @@ -12,10 +20,21 @@ public class MyObject { } @UseForGeneration - public MyObject(String string, SubObject<Integer> subObject) { + public MyObject( + @UseGenerator(StringGenerator.class) String string, + SubObject<Integer> subObject) { this(string, string.length(), subObject); } + public static class StringGenerator implements Generator<String> { + public final Generator<String> gen = stringOf(asciiCharacter()); + + @Override + public ShrinkTree<String> generate(Random random, int size) { + return gen.generate(random, size); + } + } + public MyObject add(MyObject other) { return new MyObject( this.string + other.string, diff --git a/src/test/java/au/id/zancanaro/javacheck/object/MyObjectAddTest.java b/src/test/java/au/id/zancanaro/javacheck/object/MyObjectAddTest.java index 7965449..9321acb 100644 --- a/src/test/java/au/id/zancanaro/javacheck/object/MyObjectAddTest.java +++ b/src/test/java/au/id/zancanaro/javacheck/object/MyObjectAddTest.java @@ -1,23 +1,15 @@ package au.id.zancanaro.javacheck.object; -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.Collections; - -import static au.id.zancanaro.javacheck.Generators.ofType; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; @RunWith(Properties.class) public class MyObjectAddTest { - @DataSource - public static Generator<MyObject> source = ofType(MyObject.class); - @Property public void testAdd(MyObject a, MyObject b) { MyObject added = a.add(b); diff --git a/src/test/java/au/id/zancanaro/javacheck/state/queue/commands/Offer.java b/src/test/java/au/id/zancanaro/javacheck/state/queue/commands/Offer.java index 301efeb..366e974 100644 --- a/src/test/java/au/id/zancanaro/javacheck/state/queue/commands/Offer.java +++ b/src/test/java/au/id/zancanaro/javacheck/state/queue/commands/Offer.java @@ -7,7 +7,6 @@ import au.id.zancanaro.javacheck.state.queue.QueueState; import java.util.ArrayList; import java.util.List; -import java.util.Queue; public class Offer<T> extends Command<QueueState<T>, T, Void> { public final Generator<T> generator; |