Fix test.

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/branches/pforcodec_3892@1370847 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Adrien Grand 2012-08-08 17:26:49 +00:00
parent c06b36c762
commit c8fb5b38d5
1 changed files with 3 additions and 3 deletions

View File

@ -39,7 +39,7 @@ public class TestForUtil extends LuceneTestCase {
public void testEncodeDecode() throws IOException {
final int iterations = RandomInts.randomIntBetween(random(), 1, 1000);
final float acceptableOverheadRatio = random().nextFloat();
final int[] values = new int[iterations * BLOCK_SIZE + ForUtil.MIN_DATA_SIZE];
final int[] values = new int[(iterations - 1) * BLOCK_SIZE + ForUtil.MIN_DATA_SIZE];
for (int i = 0; i < iterations; ++i) {
final int bpv = random().nextInt(32);
if (bpv == 0) {
@ -65,7 +65,7 @@ public class TestForUtil extends LuceneTestCase {
for (int i = 0; i < iterations; ++i) {
forUtil.writeBlock(
Arrays.copyOfRange(values, iterations * BLOCK_SIZE, values.length),
Arrays.copyOfRange(values, i * BLOCK_SIZE, values.length),
new byte[MIN_ENCODED_SIZE], out);
}
endPointer = out.getFilePointer();
@ -83,7 +83,7 @@ public class TestForUtil extends LuceneTestCase {
}
final int[] restored = new int[MIN_DATA_SIZE];
forUtil.readBlock(in, new byte[MIN_ENCODED_SIZE], restored);
assertArrayEquals(Arrays.copyOfRange(values, iterations * BLOCK_SIZE, (iterations + 1) * BLOCK_SIZE),
assertArrayEquals(Arrays.copyOfRange(values, i * BLOCK_SIZE, (i + 1) * BLOCK_SIZE),
Arrays.copyOf(restored, BLOCK_SIZE));
}
assertEquals(endPointer, in.getFilePointer());