LUCENE-8402: Remove invalid identityHashCode assertions in TestPriorityQueue.

This commit is contained in:
Jim Ferenczi 2018-07-20 10:13:19 +02:00
parent f6e9d00b90
commit a19bc5ecb6
1 changed files with 84 additions and 94 deletions

View File

@ -32,13 +32,6 @@ public class TestPriorityQueue extends LuceneTestCase {
@Override @Override
protected boolean lessThan(Integer a, Integer b) { protected boolean lessThan(Integer a, Integer b) {
if (a.equals(b)) {
assert (a != b);
int hashA = System.identityHashCode(a);
int hashB = System.identityHashCode(b);
assert (hashA != hashB);
return hashA < hashB;
}
return (a < b); return (a < b);
} }
@ -47,12 +40,12 @@ public class TestPriorityQueue extends LuceneTestCase {
for (int i = 1; i <= size(); i++) { for (int i = 1; i <= size(); i++) {
int parent = i >>> 1; int parent = i >>> 1;
if (parent > 1) { if (parent > 1) {
assertTrue(lessThan((Integer) heapArray[parent], if (lessThan((Integer) heapArray[parent], (Integer) heapArray[i]) == false) {
(Integer) heapArray[i])); assertEquals(heapArray[parent], heapArray[i]);
}
} }
} }
} }
} }
public void testPQ() throws Exception { public void testPQ() throws Exception {
@ -63,8 +56,7 @@ public class TestPriorityQueue extends LuceneTestCase {
PriorityQueue<Integer> pq = new IntegerQueue(count); PriorityQueue<Integer> pq = new IntegerQueue(count);
int sum = 0, sum2 = 0; int sum = 0, sum2 = 0;
for (int i = 0; i < count; i++) for (int i = 0; i < count; i++) {
{
int next = gen.nextInt(); int next = gen.nextInt();
sum += next; sum += next;
pq.add(next); pq.add(next);
@ -78,8 +70,7 @@ public class TestPriorityQueue extends LuceneTestCase {
// start = new Date(); // start = new Date();
int last = Integer.MIN_VALUE; int last = Integer.MIN_VALUE;
for (int i = 0; i < count; i++) for (int i = 0; i < count; i++) {
{
Integer next = pq.pop(); Integer next = pq.pop();
assertTrue(next.intValue() >= last); assertTrue(next.intValue() >= last);
last = next.intValue(); last = next.intValue();
@ -230,7 +221,6 @@ public class TestPriorityQueue extends LuceneTestCase {
}); });
} }
@AwaitsFix(bugUrl="https://issues.apache.org/jira/browse/LUCENE-8402")
public void testIteratorRandom() { public void testIteratorRandom() {
final int maxSize = TestUtil.nextInt(random(), 1, 20); final int maxSize = TestUtil.nextInt(random(), 1, 20);
IntegerQueue queue = new IntegerQueue(maxSize); IntegerQueue queue = new IntegerQueue(maxSize);