java.util.stream.LambdaTestHelpers Java Examples

The following examples show how to use java.util.stream.LambdaTestHelpers. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SliceOpTest.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
private ResultAsserter<Iterable<Integer>> sliceResultAsserter(Iterable<Integer> data,
                                                              int expectedSize) {
    return (act, exp, ord, par) -> {
        if (par & !ord) {
            List<Integer> expected = new ArrayList<>();
            data.forEach(expected::add);

            List<Integer> actual = new ArrayList<>();
            act.forEach(actual::add);

            assertEquals(actual.size(), expectedSize);
            assertTrue(expected.containsAll(actual));
        }
        else {
            LambdaTestHelpers.assertContents(act, exp);
        }
    };
}
 
Example #2
Source File: SliceOpTest.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
private ResultAsserter<Iterable<Integer>> sliceResultAsserter(Iterable<Integer> data,
                                                              int expectedSize) {
    return (act, exp, ord, par) -> {
        if (par & !ord) {
            List<Integer> expected = new ArrayList<>();
            data.forEach(expected::add);

            List<Integer> actual = new ArrayList<>();
            act.forEach(actual::add);

            assertEquals(actual.size(), expectedSize);
            assertTrue(expected.containsAll(actual));
        }
        else {
            LambdaTestHelpers.assertContents(act, exp);
        }
    };
}
 
Example #3
Source File: GroupByOpTest.java    From jdk8u-dev-jdk with GNU General Public License v2.0 6 votes vote down vote up
List<MapperData<Integer, ?>> getMapperData(TestData.OfRef<Integer> data) {
    int uniqueSize = data.into(new HashSet<>()).size();

    return Arrays.asList(
        new MapperData<>(mId, uniqueSize),
        new MapperData<>(mZero, Math.min(1, data.size())),
        new MapperData<>(mDoubler, uniqueSize),
        new MapperData<>(LambdaTestHelpers.compose(mId, mDoubler), uniqueSize),
        new MapperData<>(LambdaTestHelpers.compose(mDoubler, mDoubler), uniqueSize),

        new MapperData<>(LambdaTestHelpers.forPredicate(pFalse, true, false), Math.min(1, uniqueSize)),
        new MapperData<>(LambdaTestHelpers.forPredicate(pTrue, true, false), Math.min(1, uniqueSize)),
        new MapperData<>(LambdaTestHelpers.forPredicate(pEven, true, false), Math.min(2, uniqueSize)),
        new MapperData<>(LambdaTestHelpers.forPredicate(pOdd, true, false), Math.min(2, uniqueSize))
    );
}
 
Example #4
Source File: SliceOpTest.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
private ResultAsserter<Iterable<Integer>> sliceResultAsserter(Iterable<Integer> data,
                                                              int expectedSize) {
    return (act, exp, ord, par) -> {
        if (par & !ord) {
            List<Integer> expected = new ArrayList<>();
            data.forEach(expected::add);

            List<Integer> actual = new ArrayList<>();
            act.forEach(actual::add);

            assertEquals(actual.size(), expectedSize);
            assertTrue(expected.containsAll(actual));
        }
        else {
            LambdaTestHelpers.assertContents(act, exp);
        }
    };
}
 
Example #5
Source File: GroupByOpTest.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
List<MapperData<Integer, ?>> getMapperData(TestData.OfRef<Integer> data) {
    int uniqueSize = data.into(new HashSet<>()).size();

    return Arrays.asList(
        new MapperData<>(mId, uniqueSize),
        new MapperData<>(mZero, Math.min(1, data.size())),
        new MapperData<>(mDoubler, uniqueSize),
        new MapperData<>(LambdaTestHelpers.compose(mId, mDoubler), uniqueSize),
        new MapperData<>(LambdaTestHelpers.compose(mDoubler, mDoubler), uniqueSize),

        new MapperData<>(LambdaTestHelpers.forPredicate(pFalse, true, false), Math.min(1, uniqueSize)),
        new MapperData<>(LambdaTestHelpers.forPredicate(pTrue, true, false), Math.min(1, uniqueSize)),
        new MapperData<>(LambdaTestHelpers.forPredicate(pEven, true, false), Math.min(2, uniqueSize)),
        new MapperData<>(LambdaTestHelpers.forPredicate(pOdd, true, false), Math.min(2, uniqueSize))
    );
}
 
Example #6
Source File: SliceOpTest.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
private ResultAsserter<Iterable<Integer>> sliceResultAsserter(Iterable<Integer> data,
                                                              int expectedSize) {
    return (act, exp, ord, par) -> {
        if (par & !ord) {
            List<Integer> expected = new ArrayList<>();
            data.forEach(expected::add);

            List<Integer> actual = new ArrayList<>();
            act.forEach(actual::add);

            assertEquals(actual.size(), expectedSize);
            assertTrue(expected.containsAll(actual));
        }
        else {
            LambdaTestHelpers.assertContents(act, exp);
        }
    };
}
 
Example #7
Source File: InfiniteStreamWithLimitOpTest.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
private <T> ResultAsserter<Iterable<T>> unorderedAsserter() {
    return (act, exp, ord, par) -> {
        if (par & !ord) {
            // Can only assert that all elements of the actual result
            // are distinct and that the count is the limit size
            // any element within the range [0, Long.MAX_VALUE) may be
            // present
            assertUnique(act);
            long count = 0;
            for (T l : act) {
                count++;
            }
            assertEquals(count, SKIP_LIMIT_SIZE, "size not equal");
        }
        else {
            LambdaTestHelpers.assertContents(act, exp);
        }
    };
}
 
Example #8
Source File: InfiniteStreamWithLimitOpTest.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
private <T> ResultAsserter<Iterable<T>> unorderedAsserter() {
    return (act, exp, ord, par) -> {
        if (par & !ord) {
            // Can only assert that all elements of the actual result
            // are distinct and that the count is the limit size
            // any element within the range [0, Long.MAX_VALUE) may be
            // present
            assertUnique(act);
            long count = 0;
            for (T l : act) {
                count++;
            }
            assertEquals(count, SKIP_LIMIT_SIZE, "size not equal");
        }
        else {
            LambdaTestHelpers.assertContents(act, exp);
        }
    };
}
 
Example #9
Source File: SliceOpTest.java    From jdk8u-dev-jdk with GNU General Public License v2.0 6 votes vote down vote up
private ResultAsserter<Iterable<Integer>> sliceResultAsserter(Iterable<Integer> data,
                                                              int expectedSize) {
    return (act, exp, ord, par) -> {
        if (par & !ord) {
            List<Integer> expected = new ArrayList<>();
            data.forEach(expected::add);

            List<Integer> actual = new ArrayList<>();
            act.forEach(actual::add);

            assertEquals(actual.size(), expectedSize);
            assertTrue(expected.containsAll(actual));
        }
        else {
            LambdaTestHelpers.assertContents(act, exp);
        }
    };
}
 
Example #10
Source File: SliceOpTest.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
private ResultAsserter<Iterable<Integer>> sliceResultAsserter(Iterable<Integer> data,
                                                              int expectedSize) {
    return (act, exp, ord, par) -> {
        if (par & !ord) {
            List<Integer> expected = new ArrayList<>();
            data.forEach(expected::add);

            List<Integer> actual = new ArrayList<>();
            act.forEach(actual::add);

            assertEquals(actual.size(), expectedSize);
            assertTrue(expected.containsAll(actual));
        }
        else {
            LambdaTestHelpers.assertContents(act, exp);
        }
    };
}
 
Example #11
Source File: InfiniteStreamWithLimitOpTest.java    From jdk8u_jdk with GNU General Public License v2.0 6 votes vote down vote up
private <T> ResultAsserter<Iterable<T>> unorderedAsserter() {
    return (act, exp, ord, par) -> {
        if (par & !ord) {
            // Can only assert that all elements of the actual result
            // are distinct and that the count is the limit size
            // any element within the range [0, Long.MAX_VALUE) may be
            // present
            assertUnique(act);
            long count = 0;
            for (T l : act) {
                count++;
            }
            assertEquals(count, SKIP_LIMIT_SIZE, "size not equal");
        }
        else {
            LambdaTestHelpers.assertContents(act, exp);
        }
    };
}
 
Example #12
Source File: InfiniteStreamWithLimitOpTest.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
private <T> ResultAsserter<Iterable<T>> unorderedAsserter() {
    return (act, exp, ord, par) -> {
        if (par & !ord) {
            // Can only assert that all elements of the actual result
            // are distinct and that the count is the limit size
            // any element within the range [0, Long.MAX_VALUE) may be
            // present
            assertUnique(act);
            long count = 0;
            for (T l : act) {
                count++;
            }
            assertEquals(count, SKIP_LIMIT_SIZE, "size not equal");
        }
        else {
            LambdaTestHelpers.assertContents(act, exp);
        }
    };
}
 
Example #13
Source File: TabulatorsTest.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
@Test(dataProvider = "StreamTestData<Integer>", dataProviderClass = StreamTestDataProvider.class)
public void testTwoLevelPartition(String name, TestData.OfRef<Integer> data) throws ReflectiveOperationException {
    Predicate<Integer> classifier = i -> i % 3 == 0;
    Predicate<Integer> classifier2 = i -> i % 7 == 0;

    // Two level partition
    exerciseMapTabulation(data,
                          partitioningBy(classifier, partitioningBy(classifier2)),
                          new PartitionAssertion<>(classifier,
                                                   new PartitionAssertion(classifier2, new ListAssertion<>())));

    // Two level partition with reduce
    exerciseMapTabulation(data,
                          partitioningBy(classifier, reducing(0, Integer::sum)),
                          new PartitionAssertion<>(classifier,
                                                   new ReduceAssertion<>(0, LambdaTestHelpers.identity(), Integer::sum)));
}
 
Example #14
Source File: TabulatorsTest.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
@Test(dataProvider = "StreamTestData<Integer>", dataProviderClass = StreamTestDataProvider.class)
public void testTwoLevelPartition(String name, TestData.OfRef<Integer> data) throws ReflectiveOperationException {
    Predicate<Integer> classifier = i -> i % 3 == 0;
    Predicate<Integer> classifier2 = i -> i % 7 == 0;

    // Two level partition
    exerciseMapTabulation(data,
                          partitioningBy(classifier, partitioningBy(classifier2)),
                          new PartitionAssertion<>(classifier,
                                                   new PartitionAssertion(classifier2, new ListAssertion<>())));

    // Two level partition with reduce
    exerciseMapTabulation(data,
                          partitioningBy(classifier, reducing(0, Integer::sum)),
                          new PartitionAssertion<>(classifier,
                                                   new ReduceAssertion<>(0, LambdaTestHelpers.identity(), Integer::sum)));
}
 
Example #15
Source File: GroupByOpTest.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
List<MapperData<Integer, ?>> getMapperData(TestData.OfRef<Integer> data) {
    int uniqueSize = data.into(new HashSet<>()).size();

    return Arrays.asList(
        new MapperData<>(mId, uniqueSize),
        new MapperData<>(mZero, Math.min(1, data.size())),
        new MapperData<>(mDoubler, uniqueSize),
        new MapperData<>(LambdaTestHelpers.compose(mId, mDoubler), uniqueSize),
        new MapperData<>(LambdaTestHelpers.compose(mDoubler, mDoubler), uniqueSize),

        new MapperData<>(LambdaTestHelpers.forPredicate(pFalse, true, false), Math.min(1, uniqueSize)),
        new MapperData<>(LambdaTestHelpers.forPredicate(pTrue, true, false), Math.min(1, uniqueSize)),
        new MapperData<>(LambdaTestHelpers.forPredicate(pEven, true, false), Math.min(2, uniqueSize)),
        new MapperData<>(LambdaTestHelpers.forPredicate(pOdd, true, false), Math.min(2, uniqueSize))
    );
}
 
Example #16
Source File: InfiniteStreamWithLimitOpTest.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
private <T> ResultAsserter<Iterable<T>> unorderedAsserter() {
    return (act, exp, ord, par) -> {
        if (par & !ord) {
            // Can only assert that all elements of the actual result
            // are distinct and that the count is the limit size
            // any element within the range [0, Long.MAX_VALUE) may be
            // present
            assertUnique(act);
            long count = 0;
            for (T l : act) {
                count++;
            }
            assertEquals(count, SKIP_LIMIT_SIZE, "size not equal");
        }
        else {
            LambdaTestHelpers.assertContents(act, exp);
        }
    };
}
 
Example #17
Source File: TabulatorsTest.java    From jdk8u_jdk with GNU General Public License v2.0 6 votes vote down vote up
@Test(dataProvider = "StreamTestData<Integer>", dataProviderClass = StreamTestDataProvider.class)
public void testTwoLevelPartition(String name, TestData.OfRef<Integer> data) throws ReflectiveOperationException {
    Predicate<Integer> classifier = i -> i % 3 == 0;
    Predicate<Integer> classifier2 = i -> i % 7 == 0;

    // Two level partition
    exerciseMapTabulation(data,
                          partitioningBy(classifier, partitioningBy(classifier2)),
                          new PartitionAssertion<>(classifier,
                                                   new PartitionAssertion(classifier2, new ListAssertion<>())));

    // Two level partition with reduce
    exerciseMapTabulation(data,
                          partitioningBy(classifier, reducing(0, Integer::sum)),
                          new PartitionAssertion<>(classifier,
                                                   new ReduceAssertion<>(0, LambdaTestHelpers.identity(), Integer::sum)));
}
 
Example #18
Source File: InfiniteStreamWithLimitOpTest.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
private <T> ResultAsserter<Iterable<T>> unorderedAsserter() {
    return (act, exp, ord, par) -> {
        if (par & !ord) {
            // Can only assert that all elements of the actual result
            // are distinct and that the count is the limit size
            // any element within the range [0, Long.MAX_VALUE) may be
            // present
            assertUnique(act);
            long count = 0;
            for (T l : act) {
                count++;
            }
            assertEquals(count, SKIP_LIMIT_SIZE, "size not equal");
        }
        else {
            LambdaTestHelpers.assertContents(act, exp);
        }
    };
}
 
Example #19
Source File: SliceOpTest.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
private ResultAsserter<Iterable<Integer>> sliceResultAsserter(Iterable<Integer> data,
                                                              int expectedSize) {
    return (act, exp, ord, par) -> {
        if (par & !ord) {
            List<Integer> expected = new ArrayList<>();
            data.forEach(expected::add);

            List<Integer> actual = new ArrayList<>();
            act.forEach(actual::add);

            assertEquals(actual.size(), expectedSize);
            assertTrue(expected.containsAll(actual));
        }
        else {
            LambdaTestHelpers.assertContents(act, exp);
        }
    };
}
 
Example #20
Source File: TabulatorsTest.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
@Test(dataProvider = "StreamTestData<Integer>", dataProviderClass = StreamTestDataProvider.class)
public void testTwoLevelPartition(String name, TestData.OfRef<Integer> data) throws ReflectiveOperationException {
    Predicate<Integer> classifier = i -> i % 3 == 0;
    Predicate<Integer> classifier2 = i -> i % 7 == 0;

    // Two level partition
    exerciseMapTabulation(data,
                          partitioningBy(classifier, partitioningBy(classifier2)),
                          new PartitionAssertion<>(classifier,
                                                   new PartitionAssertion(classifier2, new ListAssertion<>())));

    // Two level partition with reduce
    exerciseMapTabulation(data,
                          partitioningBy(classifier, reducing(0, Integer::sum)),
                          new PartitionAssertion<>(classifier,
                                                   new ReduceAssertion<>(0, LambdaTestHelpers.identity(), Integer::sum)));
}
 
Example #21
Source File: SliceOpTest.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
private ResultAsserter<Iterable<Integer>> sliceResultAsserter(Iterable<Integer> data,
                                                              int expectedSize) {
    return (act, exp, ord, par) -> {
        if (par & !ord) {
            List<Integer> expected = new ArrayList<>();
            data.forEach(expected::add);

            List<Integer> actual = new ArrayList<>();
            act.forEach(actual::add);

            assertEquals(actual.size(), expectedSize);
            assertTrue(expected.containsAll(actual));
        }
        else {
            LambdaTestHelpers.assertContents(act, exp);
        }
    };
}
 
Example #22
Source File: InfiniteStreamWithLimitOpTest.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
private <T> ResultAsserter<Iterable<T>> unorderedAsserter() {
    return (act, exp, ord, par) -> {
        if (par & !ord) {
            // Can only assert that all elements of the actual result
            // are distinct and that the count is the limit size
            // any element within the range [0, Long.MAX_VALUE) may be
            // present
            assertUnique(act);
            long count = 0;
            for (T l : act) {
                count++;
            }
            assertEquals(count, SKIP_LIMIT_SIZE, "size not equal");
        }
        else {
            LambdaTestHelpers.assertContents(act, exp);
        }
    };
}
 
Example #23
Source File: GroupByOpTest.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
List<MapperData<Integer, ?>> getMapperData(TestData.OfRef<Integer> data) {
    int uniqueSize = data.into(new HashSet<>()).size();

    return Arrays.asList(
        new MapperData<>(mId, uniqueSize),
        new MapperData<>(mZero, Math.min(1, data.size())),
        new MapperData<>(mDoubler, uniqueSize),
        new MapperData<>(LambdaTestHelpers.compose(mId, mDoubler), uniqueSize),
        new MapperData<>(LambdaTestHelpers.compose(mDoubler, mDoubler), uniqueSize),

        new MapperData<>(LambdaTestHelpers.forPredicate(pFalse, true, false), Math.min(1, uniqueSize)),
        new MapperData<>(LambdaTestHelpers.forPredicate(pTrue, true, false), Math.min(1, uniqueSize)),
        new MapperData<>(LambdaTestHelpers.forPredicate(pEven, true, false), Math.min(2, uniqueSize)),
        new MapperData<>(LambdaTestHelpers.forPredicate(pOdd, true, false), Math.min(2, uniqueSize))
    );
}
 
Example #24
Source File: InfiniteStreamWithLimitOpTest.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
private <T> ResultAsserter<Iterable<T>> unorderedAsserter() {
    return (act, exp, ord, par) -> {
        if (par & !ord) {
            // Can only assert that all elements of the actual result
            // are distinct and that the count is the limit size
            // any element within the range [0, Long.MAX_VALUE) may be
            // present
            assertUnique(act);
            long count = 0;
            for (T l : act) {
                count++;
            }
            assertEquals(count, SKIP_LIMIT_SIZE, "size not equal");
        }
        else {
            LambdaTestHelpers.assertContents(act, exp);
        }
    };
}
 
Example #25
Source File: CollectorsTest.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
@Test(dataProvider = "StreamTestData<Integer>", dataProviderClass = StreamTestDataProvider.class)
public void testTwoLevelPartitioningBy(String name, TestData.OfRef<Integer> data) throws ReflectiveOperationException {
    Predicate<Integer> classifier = i -> i % 3 == 0;
    Predicate<Integer> classifier2 = i -> i % 7 == 0;

    // Two level partition
    exerciseMapCollection(data,
                          partitioningBy(classifier, partitioningBy(classifier2)),
                          new PartitioningByAssertion<>(classifier,
                                                        new PartitioningByAssertion(classifier2, new ToListAssertion<>())));

    // Two level partition with reduce
    exerciseMapCollection(data,
                          partitioningBy(classifier, reducing(0, Integer::sum)),
                          new PartitioningByAssertion<>(classifier,
                                                        new ReducingAssertion<>(0, LambdaTestHelpers.identity(), Integer::sum)));
}
 
Example #26
Source File: GroupByOpTest.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
List<MapperData<Integer, ?>> getMapperData(TestData.OfRef<Integer> data) {
    int uniqueSize = data.into(new HashSet<>()).size();

    return Arrays.asList(
        new MapperData<>(mId, uniqueSize),
        new MapperData<>(mZero, Math.min(1, data.size())),
        new MapperData<>(mDoubler, uniqueSize),
        new MapperData<>(LambdaTestHelpers.compose(mId, mDoubler), uniqueSize),
        new MapperData<>(LambdaTestHelpers.compose(mDoubler, mDoubler), uniqueSize),

        new MapperData<>(LambdaTestHelpers.forPredicate(pFalse, true, false), Math.min(1, uniqueSize)),
        new MapperData<>(LambdaTestHelpers.forPredicate(pTrue, true, false), Math.min(1, uniqueSize)),
        new MapperData<>(LambdaTestHelpers.forPredicate(pEven, true, false), Math.min(2, uniqueSize)),
        new MapperData<>(LambdaTestHelpers.forPredicate(pOdd, true, false), Math.min(2, uniqueSize))
    );
}
 
Example #27
Source File: InfiniteStreamWithLimitOpTest.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
private <T> ResultAsserter<Iterable<T>> unorderedAsserter() {
    return (act, exp, ord, par) -> {
        if (par & !ord) {
            // Can only assert that all elements of the actual result
            // are distinct and that the count is the limit size
            // any element within the range [0, Long.MAX_VALUE) may be
            // present
            assertUnique(act);
            long count = 0;
            for (T l : act) {
                count++;
            }
            assertEquals(count, SKIP_LIMIT_SIZE, "size not equal");
        }
        else {
            LambdaTestHelpers.assertContents(act, exp);
        }
    };
}
 
Example #28
Source File: ScannerStreamTest.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
public void findAllFileTest() {
    // derive expected result by using conventional loop
    Pattern pat = Pattern.compile("[A-Z]{7,}");
    List<String> expected = new ArrayList<>();

    try (Scanner sc = makeFileScanner(inputFile)) {
        String match;
        while ((match = sc.findWithinHorizon(pat, 0)) != null) {
            expected.add(match);
        }
    }

    Supplier<Stream<String>> ss =
        () -> makeFileScanner(inputFile).findAll(pat).map(MatchResult::group);

    withData(TestData.Factory.ofSupplier("findAllFileTest", ss))
            .stream(LambdaTestHelpers.identity())
            .expectedResult(expected)
            .exercise();
}
 
Example #29
Source File: ScannerStreamTest.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
@Test(dataProvider = "FindAllZero")
public void findAllZeroTest(String input, String patternString) {
    Pattern pattern = Pattern.compile(patternString);

    // generate expected result using Matcher.find()
    Matcher m = pattern.matcher(input);
    List<String> expected = new ArrayList<>();
    while (m.find()) {
        expected.add(m.group());
    }

    Supplier<Stream<String>> ss = () -> new Scanner(input).findAll(pattern)
                                                          .limit(100)
                                                          .map(MatchResult::group);

    withData(TestData.Factory.ofSupplier("findAllZeroTest", ss))
            .stream(LambdaTestHelpers.identity())
            .expectedResult(expected)
            .exercise();
}
 
Example #30
Source File: InfiniteStreamWithLimitOpTest.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
private <T> ResultAsserter<Iterable<T>> unorderedAsserter() {
    return (act, exp, ord, par) -> {
        if (par & !ord) {
            // Can only assert that all elements of the actual result
            // are distinct and that the count is the limit size
            // any element within the range [0, Long.MAX_VALUE) may be
            // present
            assertUnique(act);
            long count = 0;
            for (T l : act) {
                count++;
            }
            assertEquals(count, SKIP_LIMIT_SIZE, "size not equal");
        }
        else {
            LambdaTestHelpers.assertContents(act, exp);
        }
    };
}