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/11 18:28:33 UTC

[07/19] incubator-tinkerpop git commit: Add tests for IteratorUtils around count, fill and list conversion.

Add tests for IteratorUtils around count, fill and list conversion.


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

Branch: refs/heads/newapi
Commit: 8908ff0f150611d25fff548c3dd4141f4e97a6db
Parents: 243f010
Author: Stephen Mallette <sp...@apache.org>
Authored: Tue Mar 10 09:00:20 2015 -0400
Committer: Stephen Mallette <sp...@apache.org>
Committed: Tue Mar 10 09:00:20 2015 -0400

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


http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/8908ff0f/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 a0b60d9..fdd7199 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
@@ -153,6 +153,43 @@ public class IteratorUtilsTest {
         assertIterator(IteratorUtils.convertToList("test1").iterator(), 1);
     }
 
+    @Test
+    public void shouldFillFromIterator() {
+        final List<String> iterable = new ArrayList<>();
+        iterable.add("test1");
+        iterable.add("test2");
+        iterable.add("test3");
+
+        final List<String> newList = new ArrayList<>();
+        IteratorUtils.fill(iterable.iterator(), newList);
+
+        assertIterator(newList.iterator(), iterable.size());
+    }
+
+    @Test
+    public void shouldCountEmpty() {
+        final List<String> iterable = new ArrayList<>();
+        assertEquals(0, IteratorUtils.count(iterable.iterator()));
+    }
+
+    @Test
+    public void shouldCountAll() {
+        final List<String> iterable = new ArrayList<>();
+        iterable.add("test1");
+        iterable.add("test2");
+        iterable.add("test3");
+
+        assertEquals(3, IteratorUtils.count(iterable.iterator()));
+    }
+
+    @Test
+    public void shouldMakeArrayListFromIterator() {
+        final List<String> iterable = new ArrayList<>();
+        iterable.add("test1");
+        iterable.add("test2");
+        iterable.add("test3");
+        assertIterator(IteratorUtils.list(iterable.iterator()).iterator(), iterable.size());
+    }
 
     public <S> void assertIterator(final Iterator<S> itty, final int size) {
         for (int ix = 0; ix < size; ix++) {