Less warnings. Changed a priority queue test to check if updating an element and removing it works.

This commit is contained in:
Didier Le Botlan 2025-03-28 09:28:14 +01:00
parent 443539a6ba
commit 375e783c42
5 changed files with 15 additions and 2 deletions

View File

@ -83,6 +83,8 @@ public abstract class PriorityQueueTest {
public final E[] data;
public final int[] deleteOrder;
// data contains values
// deleteOrder contains indexes in data[]
public TestParameters(E[] data, int[] deleteOrder) {
this.data = data;
this.deleteOrder = deleteOrder;
@ -309,9 +311,10 @@ public abstract class PriorityQueueTest {
Assume.assumeFalse(queue.isEmpty());
int min = Collections.min(Arrays.asList(parameters.data)).get();
for (MutableInteger mi : parameters.data) {
// Update value before removing it. This is what happens when updating a Dijkstra label before updating it.
mi.set(--min);
queue.remove(mi);
assertEquals(parameters.data.length - 1, queue.size());
mi.set(--min);
queue.insert(mi);
assertEquals(parameters.data.length, queue.size());
assertEquals(min, queue.findMin().get());

View File

@ -107,6 +107,7 @@ public class PathsPanel extends JPanel
* @param path Path for this bundle, must not be null.
* @throws IOException If a resource was not found.
*/
@SuppressWarnings("deprecation")
public PathPanel(Path path, Color color) throws IOException {
super();
setLayout(new BoxLayout(this, BoxLayout.LINE_AXIS));

View File

@ -37,7 +37,7 @@ public class ThreadWrapper implements RunningAction {
return thread != null && thread.isAlive();
}
@SuppressWarnings("deprecation")
@SuppressWarnings("removal")
@Override
public void interrupt() {
thread.stop();

View File

@ -26,6 +26,7 @@ public class BinaryPathReader extends BinaryReader implements PathReader {
super(MAGIC_NUMBER, VERSION, dis);
}
@SuppressWarnings("deprecation")
@Override
public Path readPath(Graph graph) throws IOException {

View File

@ -110,6 +110,7 @@ public class PathTest {
assertEquals(10, longLoopPath.size());
}
@SuppressWarnings("deprecation")
@Test
public void testIsValid() {
assertTrue(emptyPath.isValid());
@ -122,6 +123,7 @@ public class PathTest {
assertFalse(invalidPath.isValid());
}
@SuppressWarnings("deprecation")
@Test
public void testGetLength() {
assertEquals(0, emptyPath.getLength(), 1e-6);
@ -132,6 +134,7 @@ public class PathTest {
assertEquals(120, longLoopPath.getLength(), 1e-6);
}
@SuppressWarnings("deprecation")
@Test
public void testGetTravelTime() {
// Note: 18 km/h = 5m/s
@ -151,6 +154,7 @@ public class PathTest {
assertEquals(15, longLoopPath.getTravelTime(28.8), 1e-6);
}
@SuppressWarnings("deprecation")
@Test
public void testGetMinimumTravelTime() {
assertEquals(0, emptyPath.getMinimumTravelTime(), 1e-4);
@ -161,6 +165,7 @@ public class PathTest {
assertEquals(11.25, longLoopPath.getMinimumTravelTime(), 1e-4);
}
@SuppressWarnings("deprecation")
@Test
public void testCreateFastestPathFromNodes() {
Path path;
@ -197,6 +202,7 @@ public class PathTest {
assertTrue(path.isEmpty());
}
@SuppressWarnings("deprecation")
@Test
public void testCreateShortestPathFromNodes() {
Path path;
@ -233,12 +239,14 @@ public class PathTest {
assertTrue(path.isEmpty());
}
@SuppressWarnings("deprecation")
@Test(expected = IllegalArgumentException.class)
public void testCreateFastestPathFromNodesException() {
Path.createFastestPathFromNodes(graph,
Arrays.asList(new Node[] { nodes[1], nodes[0] }));
}
@SuppressWarnings("deprecation")
@Test(expected = IllegalArgumentException.class)
public void testCreateShortestPathFromNodesException() {
Path.createShortestPathFromNodes(graph,