summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorJames Ahlborn <jtahlborn@yahoo.com>2008-03-19 01:59:48 +0000
committerJames Ahlborn <jtahlborn@yahoo.com>2008-03-19 01:59:48 +0000
commitd9bd45a7a63925b4bbd3f2dd8962ecdf1a713ad5 (patch)
treecf4d1f6c0a52ca28446e90557d6d8c4b0f3b9376 /test
parent3a521419046aefb518087b6acc5a41960eacd7b2 (diff)
downloadjackcess-d9bd45a7a63925b4bbd3f2dd8962ecdf1a713ad5.tar.gz
jackcess-d9bd45a7a63925b4bbd3f2dd8962ecdf1a713ad5.zip
add test for uniqueEntryCount updates
git-svn-id: https://svn.code.sf.net/p/jackcess/code/jackcess/trunk@286 f203690c-595d-4dc9-a70b-905162fa7fd2
Diffstat (limited to 'test')
-rw-r--r--test/src/java/com/healthmarketscience/jackcess/IndexTest.java55
1 files changed, 54 insertions, 1 deletions
diff --git a/test/src/java/com/healthmarketscience/jackcess/IndexTest.java b/test/src/java/com/healthmarketscience/jackcess/IndexTest.java
index 4b21af3..cce6c62 100644
--- a/test/src/java/com/healthmarketscience/jackcess/IndexTest.java
+++ b/test/src/java/com/healthmarketscience/jackcess/IndexTest.java
@@ -307,7 +307,60 @@ public class IndexTest extends TestCase {
}
}
}
-
+
+ public void testUniqueEntryCount() throws Exception {
+ Database db = openCopy(new File("test/data/test.mdb"));
+ Table table = db.getTable("Table1");
+ Index indA = table.getIndex("PrimaryKey");
+ Index indB = table.getIndex("B");
+
+ assertEquals(2, indA.getUniqueEntryCount());
+ assertEquals(2, indB.getUniqueEntryCount());
+
+ List<String> bElems = Arrays.asList("bar", null, "baz", "argle", null,
+ "bazzle", "37", "bar", "bar", "BAZ");
+
+ for(int i = 0; i < 10; ++i) {
+ table.addRow("foo" + i, bElems.get(i), (byte)42 + i, (short)53 + i,
+ 13 * i, (6.7d / i), null, null, true);
+ }
+
+ assertEquals(12, indA.getEntryCount());
+ assertEquals(12, indB.getEntryCount());
+
+ assertEquals(12, indA.getUniqueEntryCount());
+ assertEquals(8, indB.getUniqueEntryCount());
+
+ table = null;
+ indA = null;
+ indB = null;
+
+ table = db.getTable("Table1");
+ indA = table.getIndex("PrimaryKey");
+ indB = table.getIndex("B");
+
+ assertEquals(12, indA.getEntryCount());
+ assertEquals(12, indB.getEntryCount());
+
+ assertEquals(12, indA.getUniqueEntryCount());
+ assertEquals(8, indB.getUniqueEntryCount());
+
+ Cursor c = Cursor.createCursor(table);
+ assertTrue(c.moveToNextRow());
+ Map<String,Object> row = c.getCurrentRow();
+ assertEquals("abcdefg", row.get("A"));
+ assertEquals("hijklmnop", row.get("B"));
+ c.deleteCurrentRow();
+
+ assertEquals(11, indA.getEntryCount());
+ assertEquals(11, indB.getEntryCount());
+
+ assertEquals(12, indA.getUniqueEntryCount());
+ assertEquals(8, indB.getUniqueEntryCount());
+
+ db.close();
+ }
+
private void checkIndexColumns(Table table, String... idxInfo)
throws Exception
{