Skip to content

Commit 409fa6c

Browse files
committed
Add extra assertions to SortingTest.testSorted
SortingTest.testSorted failed in an I-build, indicating fewer matches than expected in AbstractTextSearchResult. This change adds extra assertions, to fail with the match that was not added to the result. See: #3987
1 parent 25b0279 commit 409fa6c

1 file changed

Lines changed: 14 additions & 1 deletion

File tree

  • tests/org.eclipse.search.tests/src/org/eclipse/search/tests/filesearch

tests/org.eclipse.search.tests/src/org/eclipse/search/tests/filesearch/SortingTest.java

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,10 @@
1818
import static org.junit.jupiter.api.Assertions.assertTrue;
1919

2020
import java.util.ArrayList;
21+
import java.util.Arrays;
2122
import java.util.Collections;
2223
import java.util.List;
24+
import java.util.stream.Collectors;
2325

2426
import org.junit.jupiter.api.BeforeEach;
2527
import org.junit.jupiter.api.Test;
@@ -56,15 +58,26 @@ public void testSorted() throws Exception {
5658
// first, collect all matches
5759
Object[] elements= result.getElements();
5860
for (Object element : elements) {
61+
int sizeBefore= allMatches.size();
5962
Match[] matches = result.getMatches(element);
6063
Collections.addAll(allMatches, matches);
64+
int sizeAfter= allMatches.size();
65+
assertEquals(sizeBefore + matches.length, sizeAfter, "Failed to add matches:" +
66+
Arrays.stream(matches).map(Match::toString).collect(Collectors.joining(System.lineSeparator())));
6167
}
68+
69+
assertEquals(allMatches.size(), originalMatchCount, "Unexpected match count");
70+
6271
// now remove them and readd them in reverse order
6372
result.removeAll();
6473
assertEquals(0, result.getMatchCount(), "removed all matches");
6574

6675
for (int i= allMatches.size()-1; i >= 0; i--) {
67-
result.addMatch(allMatches.get(i));
76+
Match match= allMatches.get(i);
77+
int sizeBefore= result.getMatchCount();
78+
result.addMatch(match);
79+
int sizeAfter= result.getMatchCount();
80+
assertEquals(sizeBefore + 1, sizeAfter, "Failed to add match:" + match);
6881
}
6982

7083
assertEquals(result.getMatchCount(), originalMatchCount, "Test that all matches have been added again");

0 commit comments

Comments
 (0)