From d14cd359868ad5472e9bbf1f92185af44a9c98ac Mon Sep 17 00:00:00 2001 From: James Ahlborn Date: Mon, 26 Nov 2007 04:40:55 +0000 Subject: 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 --- .../healthmarketscience/jackcess/CursorTest.java | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) (limited to 'test/src') 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 sortedRowIds = new ArrayList(new TreeSet( + 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> foundRows = new ArrayList>(); - while(cursor.moveToPreviousRow()) { - foundRows.add(cursor.getCurrentRow()); + for(Map row : cursor.reverseIterable()) { + foundRows.add(row); } assertEquals(expectedRows, foundRows); -- cgit v1.2.3