More explicit error messages in some PriorityQueue tests.

This commit is contained in:
ExtraDev
2026-05-12 18:04:39 +02:00
parent e9b5d6837f
commit ca198c7af2
@@ -237,14 +237,14 @@ public abstract class PriorityQueueTest {
max = new MutableInteger(Collections.max(data).get() + 1); max = new MutableInteger(Collections.max(data).get() + 1);
try { try {
queue.remove(min); queue.remove(min);
fail("Expected exception " + ElementNotFoundException.class.getName()); fail("Removing a non-existing element from queue succeeds. I was expecting " + ElementNotFoundException.class.getName());
} }
catch (ElementNotFoundException e) { catch (ElementNotFoundException e) {
assertEquals(min, e.getElement()); assertEquals(min, e.getElement());
} }
try { try {
queue.remove(max); queue.remove(max);
fail("Expected exception " + ElementNotFoundException.class.getName()); fail("Removing a non-existing element from queue succeeds. I was expecting " + ElementNotFoundException.class.getName());
} }
catch (ElementNotFoundException e) { catch (ElementNotFoundException e) {
assertEquals(max, e.getElement()); assertEquals(max, e.getElement());
@@ -258,7 +258,7 @@ public abstract class PriorityQueueTest {
MutableInteger min = queue.deleteMin(); MutableInteger min = queue.deleteMin();
try { try {
queue.remove(min); queue.remove(min);
fail("Expected exception " + ElementNotFoundException.class.getName()); fail("Removing an element that has just been deleted unexpectedly succeeds. I was expecting the exception " + ElementNotFoundException.class.getName());
} }
catch (ElementNotFoundException e) { catch (ElementNotFoundException e) {
assertEquals(min, e.getElement()); assertEquals(min, e.getElement());
@@ -274,7 +274,7 @@ public abstract class PriorityQueueTest {
copyQueue.remove(data); copyQueue.remove(data);
try { try {
copyQueue.remove(data); copyQueue.remove(data);
fail("Expected exception " + ElementNotFoundException.class.getName()); fail("Removing twice the same element unexpectedly succeeds. I was expecting the exception " + ElementNotFoundException.class.getName());
} }
catch (ElementNotFoundException e) { catch (ElementNotFoundException e) {
assertEquals(data, e.getElement()); assertEquals(data, e.getElement());