From 0d34df630603adc8d621b4a8d5f0294d322035d4 Mon Sep 17 00:00:00 2001 From: Michael Williamson Date: Sat, 26 Mar 2016 10:02:29 +0000 Subject: Use list-specific skip without Guava --- src/main/java/org/zwobble/mammoth/internal/util/MammothLists.java | 3 +++ src/test/java/org/zwobble/mammoth/tests/DeepReflectionMatcher.java | 6 +++--- 2 files changed, 6 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/main/java/org/zwobble/mammoth/internal/util/MammothLists.java b/src/main/java/org/zwobble/mammoth/internal/util/MammothLists.java index 463cb42..eb4dab9 100644 --- a/src/main/java/org/zwobble/mammoth/internal/util/MammothLists.java +++ b/src/main/java/org/zwobble/mammoth/internal/util/MammothLists.java @@ -71,4 +71,7 @@ public class MammothLists { } } + public static List skip(List list, int count) { + return list.subList(Math.min(list.size(), count), list.size()); + } } diff --git a/src/test/java/org/zwobble/mammoth/tests/DeepReflectionMatcher.java b/src/test/java/org/zwobble/mammoth/tests/DeepReflectionMatcher.java index 19a8043..e0a9615 100644 --- a/src/test/java/org/zwobble/mammoth/tests/DeepReflectionMatcher.java +++ b/src/test/java/org/zwobble/mammoth/tests/DeepReflectionMatcher.java @@ -1,6 +1,5 @@ package org.zwobble.mammoth.tests; -import com.google.common.collect.Iterables; import com.google.common.collect.Sets; import org.hamcrest.Description; import org.hamcrest.Matcher; @@ -18,6 +17,7 @@ import static com.google.common.collect.Iterables.any; import static java.util.Arrays.asList; import static org.zwobble.mammoth.internal.util.MammothIterables.lazyMap; import static org.zwobble.mammoth.internal.util.MammothLists.eagerFilter; +import static org.zwobble.mammoth.internal.util.MammothLists.skip; public class DeepReflectionMatcher extends TypeSafeDiagnosingMatcher { public static Matcher deepEquals(T value) { @@ -79,14 +79,14 @@ public class DeepReflectionMatcher extends TypeSafeDiagnosingMatcher { if (actual.size() > expected.size()) { appendPath(mismatchDescription, path); mismatchDescription.appendText("extra elements:" + - indentedList(lazyMap(Iterables.skip(actual, expected.size()), DeepReflectionMatcher::describeValue))); + indentedList(lazyMap(skip(actual, expected.size()), DeepReflectionMatcher::describeValue))); return false; } if (actual.size() < expected.size()) { appendPath(mismatchDescription, path); mismatchDescription.appendText("missing elements:" + - indentedList(lazyMap(Iterables.skip(expected, actual.size()), DeepReflectionMatcher::describeValue))); + indentedList(lazyMap(skip(expected, actual.size()), DeepReflectionMatcher::describeValue))); return false; } -- cgit v1.2.3