summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorJames Ahlborn <jtahlborn@yahoo.com>2007-11-26 04:40:55 +0000
committerJames Ahlborn <jtahlborn@yahoo.com>2007-11-26 04:40:55 +0000
commitd14cd359868ad5472e9bbf1f92185af44a9c98ac (patch)
tree93a1922e9096283ff5cb6145ba9ba938470b397b /test
parentd40e7e7227a22b0cb8f3cbe1f52728a8fa0e08e5 (diff)
downloadjackcess-d14cd359868ad5472e9bbf1f92185af44a9c98ac.tar.gz
jackcess-d14cd359868ad5472e9bbf1f92185af44a9c98ac.zip
further refactoring of table/cursor; initial iterator for index to allow for indexed cursors
git-svn-id: https://svn.code.sf.net/p/jackcess/code/jackcess/trunk@182 f203690c-595d-4dc9-a70b-905162fa7fd2
Diffstat (limited to 'test')
-rw-r--r--test/src/java/com/healthmarketscience/jackcess/CursorTest.java22
1 files changed, 19 insertions, 3 deletions
diff --git a/test/src/java/com/healthmarketscience/jackcess/CursorTest.java b/test/src/java/com/healthmarketscience/jackcess/CursorTest.java
index 5a0568c..ed3e5c5 100644
--- a/test/src/java/com/healthmarketscience/jackcess/CursorTest.java
+++ b/test/src/java/com/healthmarketscience/jackcess/CursorTest.java
@@ -3,9 +3,11 @@
package com.healthmarketscience.jackcess;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Map;
+import java.util.TreeSet;
import junit.framework.TestCase;
@@ -52,6 +54,21 @@ public class CursorTest extends TestCase {
return db;
}
+
+ public void testRowId() throws Exception {
+ // test special cases
+ RowId rowId1 = new RowId(1, 2);
+ RowId rowId2 = new RowId(1, 3);
+ RowId rowId3 = new RowId(2, 1);
+
+ List<RowId> sortedRowIds = new ArrayList<RowId>(new TreeSet<RowId>(
+ Arrays.asList(rowId1, rowId2, rowId3, RowId.FIRST_ROW_ID,
+ RowId.LAST_ROW_ID)));
+
+ assertEquals(Arrays.asList(RowId.FIRST_ROW_ID, rowId1, rowId2, rowId3,
+ RowId.LAST_ROW_ID),
+ sortedRowIds);
+ }
public void testSimple() throws Exception {
Database db = createTestTable();
@@ -128,11 +145,10 @@ public class CursorTest extends TestCase {
Collections.reverse(expectedRows);
Cursor cursor = Cursor.createCursor(table);
- cursor.afterLast();
List<Map<String, Object>> foundRows =
new ArrayList<Map<String, Object>>();
- while(cursor.moveToPreviousRow()) {
- foundRows.add(cursor.getCurrentRow());
+ for(Map<String, Object> row : cursor.reverseIterable()) {
+ foundRows.add(row);
}
assertEquals(expectedRows, foundRows);