diff options
author | Brian S. O'Neill <bronee@gmail.com> | 2006-09-19 06:22:33 +0000 |
---|---|---|
committer | Brian S. O'Neill <bronee@gmail.com> | 2006-09-19 06:22:33 +0000 |
commit | 86b7bd05e5e839f7d70296065f4373098e44669a (patch) | |
tree | 34b3fa3269b2917952d89e6de25119cee6270a45 /src/test/java/com/amazon | |
parent | 2278740878264362fd0f51e5f782715a89e4964f (diff) |
Added SingletonCursor.
Diffstat (limited to 'src/test/java/com/amazon')
-rw-r--r-- | src/test/java/com/amazon/carbonado/cursor/TestCursors.java | 39 |
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;
|