diff options
author | James Ahlborn <jtahlborn@yahoo.com> | 2007-11-21 15:10:48 +0000 |
---|---|---|
committer | James Ahlborn <jtahlborn@yahoo.com> | 2007-11-21 15:10:48 +0000 |
commit | 01c8f369cfa93ac9fbe54f177006fa29d846d3e7 (patch) | |
tree | 005b859db9752d3659341a62cbfebe6d0f36fe31 /test/src/java | |
parent | e39f2d1d3d4d752a276daff7710a9d91a590930b (diff) | |
download | jackcess-01c8f369cfa93ac9fbe54f177006fa29d846d3e7.tar.gz jackcess-01c8f369cfa93ac9fbe54f177006fa29d846d3e7.zip |
add reverse cursor traversal
git-svn-id: https://svn.code.sf.net/p/jackcess/code/jackcess/trunk@179 f203690c-595d-4dc9-a70b-905162fa7fd2
Diffstat (limited to 'test/src/java')
-rw-r--r-- | test/src/java/com/healthmarketscience/jackcess/CursorTest.java | 28 |
1 files changed, 24 insertions, 4 deletions
diff --git a/test/src/java/com/healthmarketscience/jackcess/CursorTest.java b/test/src/java/com/healthmarketscience/jackcess/CursorTest.java index 9e6c187..d527c0f 100644 --- a/test/src/java/com/healthmarketscience/jackcess/CursorTest.java +++ b/test/src/java/com/healthmarketscience/jackcess/CursorTest.java @@ -3,6 +3,7 @@ package com.healthmarketscience.jackcess; import java.util.ArrayList; +import java.util.Collections; import java.util.List; import java.util.Map; @@ -80,13 +81,13 @@ public class CursorTest extends TestCase { List<Map<String, Object>> foundRows = new ArrayList<Map<String, Object>>(); foundRows.add(cursor.getNextRow()); - assertEquals(3, cursor.skipRows(3)); + assertEquals(3, cursor.skipNextRows(3)); while(cursor.moveToNextRow()) { foundRows.add(cursor.getCurrentRow()); } assertEquals(expectedRows, foundRows); - assertEquals(0, cursor.skipRows(3)); + assertEquals(0, cursor.skipNextRows(3)); db.close(); } @@ -99,12 +100,12 @@ public class CursorTest extends TestCase { Cursor cursor = Cursor.createCursor(table); - assertTrue(cursor.moveToRow(table.getColumn("id"), 3)); + assertTrue(cursor.findRow(table.getColumn("id"), 3)); assertEquals(createExpectedRow("id", 3, "value", "data" + 3), cursor.getCurrentRow()); - assertTrue(cursor.moveToRow(createExpectedRow( + assertTrue(cursor.findRow(createExpectedRow( "id", 6, "value", "data" + 6))); assertEquals(createExpectedRow("id", 6, @@ -114,5 +115,24 @@ public class CursorTest extends TestCase { db.close(); } + public void testReverse() throws Exception { + Database db = createTestTable(); + + Table table = db.getTable("test"); + List<Map<String,Object>> expectedRows = createTestTableData(); + 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()); + } + assertEquals(expectedRows, foundRows); + + db.close(); + } + } |