summaryrefslogtreecommitdiff
path: root/src/test/java/com/amazon
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/java/com/amazon')
-rw-r--r--src/test/java/com/amazon/carbonado/cursor/TestCursors.java39
1 files changed, 39 insertions, 0 deletions
diff --git a/src/test/java/com/amazon/carbonado/cursor/TestCursors.java b/src/test/java/com/amazon/carbonado/cursor/TestCursors.java
index f063a59..fa5d8a7 100644
--- a/src/test/java/com/amazon/carbonado/cursor/TestCursors.java
+++ b/src/test/java/com/amazon/carbonado/cursor/TestCursors.java
@@ -20,6 +20,8 @@ package com.amazon.carbonado.cursor;
import java.util.Arrays;
import java.util.Comparator;
+import java.util.List;
+import java.util.NoSuchElementException;
import junit.framework.TestCase;
import junit.framework.TestSuite;
@@ -53,6 +55,43 @@ public class TestCursors extends TestCase {
protected void tearDown() {
}
+ public void testSingleton() throws Exception {
+ try {
+ new SingletonCursor<Object>(null);
+ fail();
+ } catch (IllegalArgumentException e) {
+ }
+
+ Cursor<String> cursor = new SingletonCursor<String>("hello");
+
+ assertTrue(cursor.hasNext());
+ assertEquals("hello", cursor.next());
+ assertFalse(cursor.hasNext());
+ try {
+ cursor.next();
+ fail();
+ } catch (NoSuchElementException e) {
+ }
+
+ assertEquals(0, cursor.skipNext(1));
+
+ cursor = new SingletonCursor<String>("world");
+ List<String> list = cursor.toList(0);
+ assertEquals(0, list.size());
+ list = cursor.toList(10);
+ assertEquals(1, list.size());
+ assertEquals("world", list.get(0));
+
+ cursor = new SingletonCursor<String>("world");
+ cursor.close();
+ assertFalse(cursor.hasNext());
+
+ cursor = new SingletonCursor<String>("world");
+ assertEquals(1, cursor.skipNext(2));
+ assertEquals(0, cursor.skipNext(1));
+ assertFalse(cursor.hasNext());
+ }
+
public void testUnion() throws Exception {
Cursor<Element> left, right, union;