mirror of https://github.com/apache/lucene.git
Add back assertions removed by LUCENE-9187. (#1236)
This time they would only apply to TestFastLZ4/TestHighLZ4 and avoid slowing down all tests.
This commit is contained in:
parent
da33e4aa6f
commit
210f2f83f7
|
@ -203,6 +203,9 @@ public final class LZ4 {
|
||||||
* offsets. A return value of {@code -1} indicates that no other index could
|
* offsets. A return value of {@code -1} indicates that no other index could
|
||||||
* be found. */
|
* be found. */
|
||||||
abstract int previous(int off);
|
abstract int previous(int off);
|
||||||
|
|
||||||
|
// For testing
|
||||||
|
abstract boolean assertReset();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -264,6 +267,11 @@ public final class LZ4 {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
boolean assertReset() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -370,6 +378,14 @@ public final class LZ4 {
|
||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
boolean assertReset() {
|
||||||
|
for (int i = 0; i < chainTable.length; ++i) {
|
||||||
|
assert chainTable[i] == (short) 0xFFFF : i;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -30,6 +30,37 @@ public abstract class LZ4TestCase extends LuceneTestCase {
|
||||||
|
|
||||||
protected abstract LZ4.HashTable newHashTable();
|
protected abstract LZ4.HashTable newHashTable();
|
||||||
|
|
||||||
|
protected static class AssertingHashTable extends LZ4.HashTable {
|
||||||
|
|
||||||
|
private final LZ4.HashTable in;
|
||||||
|
|
||||||
|
AssertingHashTable(LZ4.HashTable in) {
|
||||||
|
this.in = in;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
void reset(byte[] b, int off, int len) {
|
||||||
|
in.reset(b, off, len);
|
||||||
|
assertTrue(in.assertReset());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
int get(int off) {
|
||||||
|
return in.get(off);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
int previous(int off) {
|
||||||
|
return in.previous(off);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
boolean assertReset() {
|
||||||
|
throw new UnsupportedOperationException();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
private void doTest(byte[] data, LZ4.HashTable hashTable) throws IOException {
|
private void doTest(byte[] data, LZ4.HashTable hashTable) throws IOException {
|
||||||
int offset = random().nextBoolean()
|
int offset = random().nextBoolean()
|
||||||
? random().nextInt(10)
|
? random().nextInt(10)
|
||||||
|
|
|
@ -22,7 +22,8 @@ public class TestFastLZ4 extends LZ4TestCase {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected HashTable newHashTable() {
|
protected HashTable newHashTable() {
|
||||||
return new LZ4.FastCompressionHashTable();
|
LZ4.HashTable hashTable = new LZ4.FastCompressionHashTable();
|
||||||
|
return new AssertingHashTable(hashTable);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,7 +22,8 @@ public class TestHighLZ4 extends LZ4TestCase {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected HashTable newHashTable() {
|
protected HashTable newHashTable() {
|
||||||
return new LZ4.HighCompressionHashTable();
|
LZ4.HashTable hashTable = new LZ4.HighCompressionHashTable();
|
||||||
|
return new AssertingHashTable(hashTable);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue