From 0a1ab3559ab5039d76ca8ce453a2e9d236d8f597 Mon Sep 17 00:00:00 2001 From: James Ahlborn Date: Tue, 29 Apr 2008 16:41:30 +0000 Subject: [PATCH] test batch updates and null entries git-svn-id: https://svn.code.sf.net/p/jackcess/code/jackcess/trunk@344 f203690c-595d-4dc9-a70b-905162fa7fd2 --- .../jackcess/BigIndexTest.java | 42 +++++++++++++------ 1 file changed, 30 insertions(+), 12 deletions(-) diff --git a/test/src/java/com/healthmarketscience/jackcess/BigIndexTest.java b/test/src/java/com/healthmarketscience/jackcess/BigIndexTest.java index 0728b44..4e8e339 100644 --- a/test/src/java/com/healthmarketscience/jackcess/BigIndexTest.java +++ b/test/src/java/com/healthmarketscience/jackcess/BigIndexTest.java @@ -104,12 +104,28 @@ public class BigIndexTest extends TestCase { // add 2,000 (pseudo) random entries to the table Random rand = new Random(13L); for(int i = 0; i < 2000; ++i) { - int nextInt = rand.nextInt(Integer.MAX_VALUE); - String nextVal = "" + nextInt + extraText; - if(((i + 1) % 3333) == 0) { - nextVal = null; + if((i == 850) || (i == 1850)) { + int end = i + 50; + List rows = new ArrayList(50); + for(; i < end; ++i) { + int nextInt = rand.nextInt(Integer.MAX_VALUE); + String nextVal = "" + nextInt + extraText; + if(((i + 1) % 333) == 0) { + nextVal = null; + } + rows.add(new Object[]{nextVal, + "this is some row data " + nextInt}); + } + t.addRows(rows); + --i; + } else { + int nextInt = rand.nextInt(Integer.MAX_VALUE); + String nextVal = "" + nextInt + extraText; + if(((i + 1) % 333) == 0) { + nextVal = null; + } + t.addRow(nextVal, "this is some row data " + nextInt); } - t.addRow(nextVal, "this is some row data " + nextInt); } ((BigIndex)index).validate(); @@ -119,20 +135,22 @@ public class BigIndexTest extends TestCase { index = t.getIndex("col1"); // make sure all entries are there and correctly ordered - String lastValue = " "; + String firstValue = " "; + String prevValue = firstValue; int rowCount = 0; List firstTwo = new ArrayList(); for(Map row : Cursor.createIndexCursor(t, index)) { - String val = (String)row.get("col1"); + String origVal = (String)row.get("col1"); + String val = origVal; if(val == null) { - val = "ZZZZZZZ"; + val = firstValue; } - assertTrue("" + val + " <= " + lastValue + " " + rowCount, - lastValue.compareTo(val) <= 0); + assertTrue("" + prevValue + " <= " + val + " " + rowCount, + prevValue.compareTo(val) <= 0); if(firstTwo.size() < 2) { - firstTwo.add(val); + firstTwo.add(origVal); } - lastValue = val; + prevValue = val; ++rowCount; } -- 2.39.5