Fix order of values in assertions.
This commit is contained in:
parent
dc715744d0
commit
554b38be45
@ -110,27 +110,28 @@ public abstract class PriorityQueueTest {
|
||||
// order.
|
||||
objects.add(new TestParameters<>(
|
||||
IntStream.range(0, 20).mapToObj(MutableInteger::new).toArray(MutableInteger[]::new),
|
||||
new int[]{ 12, 17, 18, 19, 4, 5, 3, 2, 0, 9, 10, 16, 8, 14, 13, 15, 7, 6, 1, 11 }));
|
||||
new int[] { 12, 17, 18, 19, 4, 5, 3, 2, 0, 9, 10, 16, 8, 14, 13, 15, 7, 6, 1,
|
||||
11 }));
|
||||
|
||||
// Queue with 7 elements.
|
||||
objects.add(
|
||||
new TestParameters<>(
|
||||
Arrays.stream(new int[]{ 8, 1, 6, 3, 4, 5, 9 })
|
||||
Arrays.stream(new int[] { 8, 1, 6, 3, 4, 5, 9 })
|
||||
.mapToObj(MutableInteger::new).toArray(MutableInteger[]::new),
|
||||
new int[]{ 6, 5, 0, 1, 4, 2, 3 }));
|
||||
new int[] { 6, 5, 0, 1, 4, 2, 3 }));
|
||||
|
||||
// Queue with 7 elements.
|
||||
objects.add(
|
||||
new TestParameters<>(
|
||||
Arrays.stream(new int[]{ 1, 7, 4, 8, 9, 6, 5 })
|
||||
Arrays.stream(new int[] { 1, 7, 4, 8, 9, 6, 5 })
|
||||
.mapToObj(MutableInteger::new).toArray(MutableInteger[]::new),
|
||||
new int[]{ 2, 0, 1, 3, 4, 5, 6 }));
|
||||
new int[] { 2, 0, 1, 3, 4, 5, 6 }));
|
||||
|
||||
// Queue with 13 elements.
|
||||
objects.add(new TestParameters<>(
|
||||
Arrays.stream(new int[]{ 1, 7, 2, 8, 9, 3, 4, 10, 11, 12, 13, 5, 6 })
|
||||
Arrays.stream(new int[] { 1, 7, 2, 8, 9, 3, 4, 10, 11, 12, 13, 5, 6 })
|
||||
.mapToObj(MutableInteger::new).toArray(MutableInteger[]::new),
|
||||
new int[]{ 3, 4, 0, 2, 5, 6, 1, 7, 8, 9, 10, 11, 12 }));
|
||||
new int[] { 3, 4, 0, 2, 5, 6, 1, 7, 8, 9, 10, 11, 12 }));
|
||||
|
||||
return objects;
|
||||
}
|
||||
@ -200,7 +201,7 @@ public abstract class PriorityQueueTest {
|
||||
@Test
|
||||
public void testDeleteMin() {
|
||||
int size = parameters.data.length;
|
||||
assertEquals(queue.size(), size);
|
||||
assertEquals(size, queue.size());
|
||||
MutableInteger[] range = Arrays.copyOf(parameters.data, parameters.data.length);
|
||||
Arrays.sort(range);
|
||||
for (MutableInteger x: range) {
|
||||
@ -229,14 +230,14 @@ public abstract class PriorityQueueTest {
|
||||
fail("Expected exception " + ElementNotFoundException.class.getName());
|
||||
}
|
||||
catch (ElementNotFoundException e) {
|
||||
assertEquals(e.getElement(), min);
|
||||
assertEquals(min, e.getElement());
|
||||
}
|
||||
try {
|
||||
queue.remove(max);
|
||||
fail("Expected exception " + ElementNotFoundException.class.getName());
|
||||
}
|
||||
catch (ElementNotFoundException e) {
|
||||
assertEquals(e.getElement(), max);
|
||||
assertEquals(max, e.getElement());
|
||||
}
|
||||
}
|
||||
|
||||
@ -250,7 +251,7 @@ public abstract class PriorityQueueTest {
|
||||
fail("Expected exception " + ElementNotFoundException.class.getName());
|
||||
}
|
||||
catch (ElementNotFoundException e) {
|
||||
assertEquals(e.getElement(), min);
|
||||
assertEquals(min, e.getElement());
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -266,7 +267,7 @@ public abstract class PriorityQueueTest {
|
||||
fail("Expected exception " + ElementNotFoundException.class.getName());
|
||||
}
|
||||
catch (ElementNotFoundException e) {
|
||||
assertEquals(e.getElement(), data);
|
||||
assertEquals(data, e.getElement());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -83,26 +83,26 @@ public class GraphTest {
|
||||
assertEquals(expNbSucc[i], transpose.get(i).getNumberOfSuccessors());
|
||||
}
|
||||
|
||||
assertEquals(getArcsBetween(transpose.get(0), transpose.get(1)).size(), 1);
|
||||
assertEquals(getArcsBetween(transpose.get(0), transpose.get(2)).size(), 1);
|
||||
assertEquals(getArcsBetween(transpose.get(0), transpose.get(3)).size(), 1);
|
||||
assertEquals(getArcsBetween(transpose.get(0), transpose.get(4)).size(), 1);
|
||||
assertEquals(getArcsBetween(transpose.get(1), transpose.get(0)).size(), 1);
|
||||
assertEquals(getArcsBetween(transpose.get(1), transpose.get(2)).size(), 1);
|
||||
assertEquals(getArcsBetween(transpose.get(1), transpose.get(3)).size(), 0);
|
||||
assertEquals(getArcsBetween(transpose.get(1), transpose.get(4)).size(), 0);
|
||||
assertEquals(getArcsBetween(transpose.get(2), transpose.get(0)).size(), 1);
|
||||
assertEquals(getArcsBetween(transpose.get(2), transpose.get(1)).size(), 1);
|
||||
assertEquals(getArcsBetween(transpose.get(2), transpose.get(3)).size(), 0);
|
||||
assertEquals(getArcsBetween(transpose.get(2), transpose.get(4)).size(), 0);
|
||||
assertEquals(getArcsBetween(transpose.get(3), transpose.get(0)).size(), 1);
|
||||
assertEquals(getArcsBetween(transpose.get(3), transpose.get(1)).size(), 0);
|
||||
assertEquals(getArcsBetween(transpose.get(3), transpose.get(2)).size(), 3);
|
||||
assertEquals(getArcsBetween(transpose.get(3), transpose.get(4)).size(), 0);
|
||||
assertEquals(getArcsBetween(transpose.get(4), transpose.get(0)).size(), 1);
|
||||
assertEquals(getArcsBetween(transpose.get(4), transpose.get(1)).size(), 0);
|
||||
assertEquals(getArcsBetween(transpose.get(4), transpose.get(2)).size(), 0);
|
||||
assertEquals(getArcsBetween(transpose.get(4), transpose.get(3)).size(), 1);
|
||||
assertEquals(1, getArcsBetween(transpose.get(0), transpose.get(1)).size());
|
||||
assertEquals(1, getArcsBetween(transpose.get(0), transpose.get(2)).size());
|
||||
assertEquals(1, getArcsBetween(transpose.get(0), transpose.get(3)).size());
|
||||
assertEquals(1, getArcsBetween(transpose.get(0), transpose.get(4)).size());
|
||||
assertEquals(1, getArcsBetween(transpose.get(1), transpose.get(0)).size());
|
||||
assertEquals(1, getArcsBetween(transpose.get(1), transpose.get(2)).size());
|
||||
assertEquals(0, getArcsBetween(transpose.get(1), transpose.get(3)).size());
|
||||
assertEquals(0, getArcsBetween(transpose.get(1), transpose.get(4)).size());
|
||||
assertEquals(1, getArcsBetween(transpose.get(2), transpose.get(0)).size());
|
||||
assertEquals(1, getArcsBetween(transpose.get(2), transpose.get(1)).size());
|
||||
assertEquals(0, getArcsBetween(transpose.get(2), transpose.get(3)).size());
|
||||
assertEquals(0, getArcsBetween(transpose.get(2), transpose.get(4)).size());
|
||||
assertEquals(1, getArcsBetween(transpose.get(3), transpose.get(0)).size());
|
||||
assertEquals(0, getArcsBetween(transpose.get(3), transpose.get(1)).size());
|
||||
assertEquals(3, getArcsBetween(transpose.get(3), transpose.get(2)).size());
|
||||
assertEquals(0, getArcsBetween(transpose.get(3), transpose.get(4)).size());
|
||||
assertEquals(1, getArcsBetween(transpose.get(4), transpose.get(0)).size());
|
||||
assertEquals(0, getArcsBetween(transpose.get(4), transpose.get(1)).size());
|
||||
assertEquals(0, getArcsBetween(transpose.get(4), transpose.get(2)).size());
|
||||
assertEquals(1, getArcsBetween(transpose.get(4), transpose.get(3)).size());
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -65,18 +65,18 @@ public class NodeTest {
|
||||
@Test
|
||||
public void testGetNumberOfSuccessors() {
|
||||
final int[] expNbSucc = { 4, 2, 5, 2, 1, 0 };
|
||||
assertEquals(nodes.length, expNbSucc.length);
|
||||
assertEquals(expNbSucc.length, nodes.length);
|
||||
for (int i = 0; i < expNbSucc.length; ++i) {
|
||||
assertEquals(nodes[i].getNumberOfSuccessors(), expNbSucc[i]);
|
||||
assertEquals(expNbSucc[i], nodes[i].getNumberOfSuccessors());
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testHasSuccessors() {
|
||||
final int[] expNbSucc = { 4, 2, 5, 2, 1, 0 };
|
||||
assertEquals(nodes.length, expNbSucc.length);
|
||||
assertEquals(expNbSucc.length, nodes.length);
|
||||
for (int i = 0; i < expNbSucc.length; ++i) {
|
||||
assertEquals(nodes[i].hasSuccessors(), expNbSucc[i] != 0);
|
||||
assertEquals(expNbSucc[i] != 0, nodes[i].hasSuccessors());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -96,12 +96,12 @@ public class PathTest {
|
||||
|
||||
@Test
|
||||
public void testSize() {
|
||||
assertEquals(emptyPath.size(), 0);
|
||||
assertEquals(singleNodePath.size(), 1);
|
||||
assertEquals(shortPath.size(), 4);
|
||||
assertEquals(longPath.size(), 5);
|
||||
assertEquals(loopPath.size(), 5);
|
||||
assertEquals(longLoopPath.size(), 10);
|
||||
assertEquals(0, emptyPath.size());
|
||||
assertEquals(1, singleNodePath.size());
|
||||
assertEquals(4, shortPath.size());
|
||||
assertEquals(5, longPath.size());
|
||||
assertEquals(5, loopPath.size());
|
||||
assertEquals(10, longLoopPath.size());
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -118,41 +118,41 @@ public class PathTest {
|
||||
|
||||
@Test
|
||||
public void testGetLength() {
|
||||
assertEquals(emptyPath.getLength(), 0, 1e-6);
|
||||
assertEquals(singleNodePath.getLength(), 0, 1e-6);
|
||||
assertEquals(shortPath.getLength(), 40, 1e-6);
|
||||
assertEquals(longPath.getLength(), 62.8, 1e-6);
|
||||
assertEquals(loopPath.getLength(), 55, 1e-6);
|
||||
assertEquals(longLoopPath.getLength(), 120, 1e-6);
|
||||
assertEquals(0, emptyPath.getLength(), 1e-6);
|
||||
assertEquals(0, singleNodePath.getLength(), 1e-6);
|
||||
assertEquals(40, shortPath.getLength(), 1e-6);
|
||||
assertEquals(62.8, longPath.getLength(), 1e-6);
|
||||
assertEquals(55, loopPath.getLength(), 1e-6);
|
||||
assertEquals(120, longLoopPath.getLength(), 1e-6);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetTravelTime() {
|
||||
// Note: 18 km/h = 5m/s
|
||||
assertEquals(emptyPath.getTravelTime(18), 0, 1e-6);
|
||||
assertEquals(singleNodePath.getTravelTime(18), 0, 1e-6);
|
||||
assertEquals(shortPath.getTravelTime(18), 8, 1e-6);
|
||||
assertEquals(longPath.getTravelTime(18), 12.56, 1e-6);
|
||||
assertEquals(loopPath.getTravelTime(18), 11, 1e-6);
|
||||
assertEquals(longLoopPath.getTravelTime(18), 24, 1e-6);
|
||||
assertEquals(0, emptyPath.getTravelTime(18), 1e-6);
|
||||
assertEquals(0, singleNodePath.getTravelTime(18), 1e-6);
|
||||
assertEquals(8, shortPath.getTravelTime(18), 1e-6);
|
||||
assertEquals(12.56, longPath.getTravelTime(18), 1e-6);
|
||||
assertEquals(11, loopPath.getTravelTime(18), 1e-6);
|
||||
assertEquals(24, longLoopPath.getTravelTime(18), 1e-6);
|
||||
|
||||
// Note: 28.8 km/h = 8m/s
|
||||
assertEquals(emptyPath.getTravelTime(28.8), 0, 1e-6);
|
||||
assertEquals(singleNodePath.getTravelTime(28.8), 0, 1e-6);
|
||||
assertEquals(shortPath.getTravelTime(28.8), 5, 1e-6);
|
||||
assertEquals(longPath.getTravelTime(28.8), 7.85, 1e-6);
|
||||
assertEquals(loopPath.getTravelTime(28.8), 6.875, 1e-6);
|
||||
assertEquals(longLoopPath.getTravelTime(28.8), 15, 1e-6);
|
||||
assertEquals(0, emptyPath.getTravelTime(28.8), 1e-6);
|
||||
assertEquals(0, singleNodePath.getTravelTime(28.8), 1e-6);
|
||||
assertEquals(5, shortPath.getTravelTime(28.8), 1e-6);
|
||||
assertEquals(7.85, longPath.getTravelTime(28.8), 1e-6);
|
||||
assertEquals(6.875, loopPath.getTravelTime(28.8), 1e-6);
|
||||
assertEquals(15, longLoopPath.getTravelTime(28.8), 1e-6);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetMinimumTravelTime() {
|
||||
assertEquals(emptyPath.getMinimumTravelTime(), 0, 1e-4);
|
||||
assertEquals(singleNodePath.getLength(), 0, 1e-4);
|
||||
assertEquals(shortPath.getMinimumTravelTime(), 4, 1e-4);
|
||||
assertEquals(longPath.getMinimumTravelTime(), 5.14, 1e-4);
|
||||
assertEquals(loopPath.getMinimumTravelTime(), 5.5, 1e-4);
|
||||
assertEquals(longLoopPath.getMinimumTravelTime(), 11.25, 1e-4);
|
||||
assertEquals(0, emptyPath.getMinimumTravelTime(), 1e-4);
|
||||
assertEquals(0, singleNodePath.getLength(), 1e-4);
|
||||
assertEquals(4, shortPath.getMinimumTravelTime(), 1e-4);
|
||||
assertEquals(5.14, longPath.getMinimumTravelTime(), 1e-4);
|
||||
assertEquals(5.5, loopPath.getMinimumTravelTime(), 1e-4);
|
||||
assertEquals(11.25, longLoopPath.getMinimumTravelTime(), 1e-4);
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -180,13 +180,13 @@ public class PathTest {
|
||||
|
||||
// Trap construction!
|
||||
path = Path.createFastestPathFromNodes(graph, Arrays.asList(new Node[] { nodes[1] }));
|
||||
assertEquals(path.getOrigin(), nodes[1]);
|
||||
assertEquals(path.getArcs().size(), 0);
|
||||
assertEquals(nodes[1], path.getOrigin());
|
||||
assertEquals(0, path.getArcs().size());
|
||||
|
||||
// Trap construction - The return!
|
||||
path = Path.createFastestPathFromNodes(graph, Arrays.asList(new Node[0]));
|
||||
assertEquals(path.getOrigin(), null);
|
||||
assertEquals(path.getArcs().size(), 0);
|
||||
assertEquals(null, path.getOrigin());
|
||||
assertEquals(0, path.getArcs().size());
|
||||
assertTrue(path.isEmpty());
|
||||
}
|
||||
|
||||
@ -215,13 +215,13 @@ public class PathTest {
|
||||
|
||||
// Trap construction!
|
||||
path = Path.createShortestPathFromNodes(graph, Arrays.asList(new Node[] { nodes[1] }));
|
||||
assertEquals(path.getOrigin(), nodes[1]);
|
||||
assertEquals(path.getArcs().size(), 0);
|
||||
assertEquals(nodes[1], path.getOrigin());
|
||||
assertEquals(0, path.getArcs().size());
|
||||
|
||||
// Trap construction - The return!
|
||||
path = Path.createShortestPathFromNodes(graph, Arrays.asList(new Node[0]));
|
||||
assertEquals(path.getOrigin(), null);
|
||||
assertEquals(path.getArcs().size(), 0);
|
||||
assertEquals(null, path.getOrigin());
|
||||
assertEquals(0, path.getArcs().size());
|
||||
assertTrue(path.isEmpty());
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user