diff options
Diffstat (limited to 'src/test/java/au')
-rw-r--r-- | src/test/java/au/id/zancanaro/javacheck/ListFunctorRulesTest.java | 61 | ||||
-rw-r--r-- | src/test/java/au/id/zancanaro/javacheck/SimpleListOperationsTest.java | 1 |
2 files changed, 31 insertions, 31 deletions
diff --git a/src/test/java/au/id/zancanaro/javacheck/ListFunctorRulesTest.java b/src/test/java/au/id/zancanaro/javacheck/ListFunctorRulesTest.java index 4e516a2..b757bcd 100644 --- a/src/test/java/au/id/zancanaro/javacheck/ListFunctorRulesTest.java +++ b/src/test/java/au/id/zancanaro/javacheck/ListFunctorRulesTest.java @@ -19,27 +19,27 @@ public class ListFunctorRulesTest { private final static int maxSize = 1000; @DataSource - public static Generator<List<Integer>> listOfIntegers = listOf(integer()); + public static Generator<List<Long>> listOfIntegers = listOf(longInteger()); @DataSource - public static Generator<Function<Integer, Integer>> integerFunction = + public static Generator<Function<Long, Long>> integerFunction = oneOf( - integer().map(ListFunctorRulesTest::plusI), - integer().map(ListFunctorRulesTest::timesI), - integer().map(ListFunctorRulesTest::constantlyI)); + longInteger().map(ListFunctorRulesTest::plusI), + longInteger().map(ListFunctorRulesTest::timesI), + longInteger().map(ListFunctorRulesTest::constantlyI)); @Property(maxSize = maxSize, runs = runs) public void mappingCompositionsWithStreams( - List<Integer> list, - Function<Integer, Integer> f, - Function<Integer, Integer> g) { - List<Integer> left = list.stream() + List<Long> list, + Function<Long, Long> f, + Function<Long, Long> g) { + List<Long> left = list.stream() .map(g) .map(f) .collect(Collectors.toList()); - List<Integer> right = list.stream() - .map(x -> f.apply(g.apply(x))) + List<Long> right = list.stream() + .map(f.compose(g)) .collect(Collectors.toList()); assertEquals(left, right); @@ -47,30 +47,30 @@ public class ListFunctorRulesTest { @Property(maxSize = maxSize, runs = runs) public void mappingCompositionsWithIntermediateList( - List<Integer> list, - Function<Integer, Integer> f, - Function<Integer, Integer> g) { - List<Integer> intermediate = list.stream().map(g).collect(Collectors.toList()); - List<Integer> left = intermediate.stream().map(f).collect(Collectors.toList()); - - List<Integer> right = list.stream() - .map(x -> f.apply(g.apply(x))) + List<Long> list, + Function<Long, Long> f, + Function<Long, Long> g) { + List<Long> intermediate = list.stream().map(g).collect(Collectors.toList()); + List<Long> left = intermediate.stream().map(f).collect(Collectors.toList()); + + List<Long> right = list.stream() + .map(f.compose(g)) .collect(Collectors.toList()); assertEquals(left, right); } @Property(maxSize = maxSize, runs = runs) - public void mapIdentityIsIdentity(List<Integer> list) { - List<Integer> mapped = list.stream().map(x -> x).collect(Collectors.toList()); + public void mapIdentityIsIdentity(List<Long> list) { + List<Long> mapped = list.stream().map(x -> x).collect(Collectors.toList()); assertEquals(list, mapped); } - private static Function<Integer,Integer> plusI(final int i) { - return new Function<Integer, Integer>() { + private static Function<Long, Long> plusI(final long i) { + return new Function<Long, Long>() { @Override - public Integer apply(Integer integer) { + public Long apply(Long integer) { return i + integer; } @@ -81,10 +81,10 @@ public class ListFunctorRulesTest { }; } - private static Function<Integer,Integer> timesI(final int i) { - return new Function<Integer, Integer>() { + private static Function<Long, Long> timesI(final long i) { + return new Function<Long, Long>() { @Override - public Integer apply(Integer integer) { + public Long apply(Long integer) { return i * integer; } @@ -94,10 +94,11 @@ public class ListFunctorRulesTest { } }; } - private static Function<Integer,Integer> constantlyI(final int i) { - return new Function<Integer, Integer>() { + + private static Function<Long, Long> constantlyI(final long i) { + return new Function<Long, Long>() { @Override - public Integer apply(Integer integer) { + public Long apply(Long integer) { return i; } diff --git a/src/test/java/au/id/zancanaro/javacheck/SimpleListOperationsTest.java b/src/test/java/au/id/zancanaro/javacheck/SimpleListOperationsTest.java index 972b5b6..8f7b075 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.Generator; import au.id.zancanaro.javacheck.annotations.DataSource; import au.id.zancanaro.javacheck.annotations.Property; import au.id.zancanaro.javacheck.junit.Properties; |