You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tinkerpop.apache.org by sp...@apache.org on 2015/03/10 14:12:26 UTC

incubator-tinkerpop git commit: Add tests for IteratorUtils for match functions.

Repository: incubator-tinkerpop
Updated Branches:
  refs/heads/master 8908ff0f1 -> b2c673c2a


Add tests for IteratorUtils for match functions.


Project: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/commit/b2c673c2
Tree: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/tree/b2c673c2
Diff: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/diff/b2c673c2

Branch: refs/heads/master
Commit: b2c673c2ac36cd2bce405878322d34c37dfe9366
Parents: 8908ff0
Author: Stephen Mallette <sp...@apache.org>
Authored: Tue Mar 10 09:12:02 2015 -0400
Committer: Stephen Mallette <sp...@apache.org>
Committed: Tue Mar 10 09:12:02 2015 -0400

----------------------------------------------------------------------
 .../util/iterator/IteratorUtilsTest.java        | 55 ++++++++++++++++++++
 1 file changed, 55 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/b2c673c2/gremlin-test/src/test/java/org/apache/tinkerpop/gremlin/util/iterator/IteratorUtilsTest.java
----------------------------------------------------------------------
diff --git a/gremlin-test/src/test/java/org/apache/tinkerpop/gremlin/util/iterator/IteratorUtilsTest.java b/gremlin-test/src/test/java/org/apache/tinkerpop/gremlin/util/iterator/IteratorUtilsTest.java
index fdd7199..f039c4e 100644
--- a/gremlin-test/src/test/java/org/apache/tinkerpop/gremlin/util/iterator/IteratorUtilsTest.java
+++ b/gremlin-test/src/test/java/org/apache/tinkerpop/gremlin/util/iterator/IteratorUtilsTest.java
@@ -8,6 +8,7 @@ import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 
+import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
 
@@ -191,6 +192,60 @@ public class IteratorUtilsTest {
         assertIterator(IteratorUtils.list(iterable.iterator()).iterator(), iterable.size());
     }
 
+    @Test
+    public void shouldMatchAllPositively() {
+        final List<String> iterable = new ArrayList<>();
+        iterable.add("test1");
+        iterable.add("test2");
+        iterable.add("test3");
+        assertTrue(IteratorUtils.allMatch(iterable.iterator(), s -> s.startsWith("test")));
+    }
+
+    @Test
+    public void shouldMatchAllNegatively() {
+        final List<String> iterable = new ArrayList<>();
+        iterable.add("test1");
+        iterable.add("test2");
+        iterable.add("test3");
+        assertFalse(IteratorUtils.allMatch(iterable.iterator(), s -> s.startsWith("test1")));
+    }
+
+    @Test
+    public void shouldMatchAnyPositively() {
+        final List<String> iterable = new ArrayList<>();
+        iterable.add("test1");
+        iterable.add("test2");
+        iterable.add("test3");
+        assertTrue(IteratorUtils.anyMatch(iterable.iterator(), s -> s.startsWith("test3")));
+    }
+
+    @Test
+    public void shouldMatchAnyNegatively() {
+        final List<String> iterable = new ArrayList<>();
+        iterable.add("test1");
+        iterable.add("test2");
+        iterable.add("test3");
+        assertFalse(IteratorUtils.anyMatch(iterable.iterator(), s -> s.startsWith("dfaa")));
+    }
+
+    @Test
+    public void shouldMatchNonePositively() {
+        final List<String> iterable = new ArrayList<>();
+        iterable.add("test1");
+        iterable.add("test2");
+        iterable.add("test3");
+        assertTrue(IteratorUtils.noneMatch(iterable.iterator(), s -> s.startsWith("test4")));
+    }
+
+    @Test
+    public void shouldMatchNoneNegatively() {
+        final List<String> iterable = new ArrayList<>();
+        iterable.add("test1");
+        iterable.add("test2");
+        iterable.add("test3");
+        assertFalse(IteratorUtils.noneMatch(iterable.iterator(), s -> s.startsWith("test")));
+    }
+
     public <S> void assertIterator(final Iterator<S> itty, final int size) {
         for (int ix = 0; ix < size; ix++) {
             assertEquals("test" + (ix + 1), itty.next());