A comment to indicate that this test (modify an element then remove) may rightly fail in some cases. Changed also the name of the test to indicate that the value is changed.

This commit is contained in:
ExtraDev
2026-05-07 11:28:14 +02:00
parent 85519ae898
commit e9b5d6837f
@@ -314,7 +314,14 @@ public abstract class PriorityQueueTest {
} }
@Test @Test
public void testRemoveThenAdd() { /**
* This test may fail if your algorithm for remove assumes the heap is well-formed
* (i.e. you assume the element to remove is at its right position).
*
* In that case, you can remove this test, but note that remove must always be invoked on a well-formed heap.
* In particular, in your Dijkstra implementation, do not modify an element that is in the heap.
*/
public void ModifyInPlaceThenRemoveThenAdd() {
Assume.assumeFalse(queue.isEmpty()); Assume.assumeFalse(queue.isEmpty());
int min = Collections.min(Arrays.asList(parameters.data)).get(); int min = Collections.min(Arrays.asList(parameters.data)).get();
for (MutableInteger mi : parameters.data) { for (MutableInteger mi : parameters.data) {