jpountz commented on a change in pull request #1937:
URL: https://github.com/apache/lucene-solr/pull/1937#discussion_r499180389
##########
File path:
lucene/core/src/test/org/apache/lucene/search/TestConjunctionDISI.java
##########
@@ -391,4 +391,20 @@ public void testCollapseSubConjunctionDISIs() throws
IOException {
public void testCollapseSubConjunctionScorers() throws IOException {
testCollapseSubConjunctions(true);
}
+
+ public void testIllegalAdvancementOfSubIteratorsTripsAssertion() throws
IOException {
+ int maxDoc = 100;
Review comment:
I think we need to call something like `assumeTrue(assertsAreEnabled)`
since this test requires assertions to be enabled to succeed.
##########
File path:
lucene/core/src/test/org/apache/lucene/search/TestConjunctionDISI.java
##########
@@ -391,4 +391,20 @@ public void testCollapseSubConjunctionDISIs() throws
IOException {
public void testCollapseSubConjunctionScorers() throws IOException {
testCollapseSubConjunctions(true);
}
+
+ public void testIllegalAdvancementOfSubIteratorsTripsAssertion() throws
IOException {
+ int maxDoc = 100;
+ final int numIterators = TestUtil.nextInt(random(), 2, 5);
+ FixedBitSet set = randomSet(maxDoc);
+
+ DocIdSetIterator[] iterators = new DocIdSetIterator[numIterators];
+ for (int i = 0; i < iterators.length; ++i) {
+ iterators[i] = new BitDocIdSet(set).iterator();
+ }
+ final DocIdSetIterator conjunction =
ConjunctionDISI.intersectIterators(Arrays.asList(iterators));
+ int idx = TestUtil.nextInt(random() , 0, iterators.length-1);
+ iterators[idx].nextDoc(); // illegally advancing one of the sub-iterators
outside of the conjunction iterator
+ AssertionError ex = expectThrows(AssertionError.class, () ->
conjunction.nextDoc());
+ assertEquals(ex.getMessage(), "Sub-iterators of ConjunctionDISI are not
the same document!");
Review comment:
can you revert the two arguments to assertEquals? it expects the
expected value first and the actual value second. While swapping arguments
doesn't cause major issues, it creates confusing error messages when the
assertion fails.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]