You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@lucene.apache.org by GitBox <gi...@apache.org> on 2022/03/30 05:42:46 UTC
[GitHub] [lucene] dweiss commented on a change in pull request #770: Implement method to bulk add all collection elements to a PriorityQueue
dweiss commented on a change in pull request #770:
URL: https://github.com/apache/lucene/pull/770#discussion_r838137561
##########
File path: lucene/core/src/test/org/apache/lucene/util/TestPriorityQueue.java
##########
@@ -163,6 +164,57 @@ public void testInsertWithOverflow() {
assertEquals((Integer) 2, pq.top());
}
+ public void testAddAllToEmptyQueue() {
+ Random random = random();
+ int size = 10;
+ List<Integer> list = new ArrayList<>();
+ for (int i = 0; i < size; i++) {
+ list.add(random.nextInt());
+ }
+ IntegerQueue pq = new IntegerQueue(size);
+ pq.addAll(list);
+
+ pq.checkValidity();
+ assertOrderedWhenDrained(pq, list);
+ }
+
+
+
+ public void testAddAllToPartiallyFilledQueue() {
+ IntegerQueue pq = new IntegerQueue(20);
+ List<Integer> oneByOne = new ArrayList<>();
+ List<Integer> bulkAdded = new ArrayList<>();
+ Random random = random();
+ for (int i = 0; i < 10; i++) {
+ bulkAdded.add(random.nextInt());
+
+ int x = random.nextInt();
+ pq.add(x);
+ oneByOne.add(x);
+ }
+
+ pq.addAll(bulkAdded);
+ pq.checkValidity();
+
+ oneByOne.addAll(bulkAdded); // Gather all "reference" data.
+ assertOrderedWhenDrained(pq, oneByOne);
+ }
+
+ public void testAddAllDontFitIntoQueue() {
Review comment:
```suggestion
public void testAddAllDoesNotFitIntoQueue() {
```
##########
File path: lucene/core/src/test/org/apache/lucene/util/TestPriorityQueue.java
##########
@@ -163,6 +164,57 @@ public void testInsertWithOverflow() {
assertEquals((Integer) 2, pq.top());
}
+ public void testAddAllToEmptyQueue() {
+ Random random = random();
+ int size = 10;
+ List<Integer> list = new ArrayList<>();
+ for (int i = 0; i < size; i++) {
+ list.add(random.nextInt());
+ }
+ IntegerQueue pq = new IntegerQueue(size);
+ pq.addAll(list);
+
+ pq.checkValidity();
+ assertOrderedWhenDrained(pq, list);
+ }
+
Review comment:
I think you'll have to run 'gradlew tidy' to clean up formatting here.
--
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.
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org