Browse Source

Fix order of values in assertions.

Mikaël Capelle 2 years ago
parent
commit
554b38be45

+ 13
- 12
src/test/org/insa/algo/utils/PriorityQueueTest.java View File

@@ -110,27 +110,28 @@ public abstract class PriorityQueueTest {
110 110
         // order.
111 111
         objects.add(new TestParameters<>(
112 112
                 IntStream.range(0, 20).mapToObj(MutableInteger::new).toArray(MutableInteger[]::new),
113
-                new int[]{ 12, 17, 18, 19, 4, 5, 3, 2, 0, 9, 10, 16, 8, 14, 13, 15, 7, 6, 1, 11 }));
113
+                new int[] { 12, 17, 18, 19, 4, 5, 3, 2, 0, 9, 10, 16, 8, 14, 13, 15, 7, 6, 1,
114
+                        11 }));
114 115
 
115 116
         // Queue with 7 elements.
116 117
         objects.add(
117 118
                 new TestParameters<>(
118
-                        Arrays.stream(new int[]{ 8, 1, 6, 3, 4, 5, 9 })
119
+                        Arrays.stream(new int[] { 8, 1, 6, 3, 4, 5, 9 })
119 120
                                 .mapToObj(MutableInteger::new).toArray(MutableInteger[]::new),
120
-                        new int[]{ 6, 5, 0, 1, 4, 2, 3 }));
121
+                        new int[] { 6, 5, 0, 1, 4, 2, 3 }));
121 122
 
122 123
         // Queue with 7 elements.
123 124
         objects.add(
124 125
                 new TestParameters<>(
125
-                        Arrays.stream(new int[]{ 1, 7, 4, 8, 9, 6, 5 })
126
+                        Arrays.stream(new int[] { 1, 7, 4, 8, 9, 6, 5 })
126 127
                                 .mapToObj(MutableInteger::new).toArray(MutableInteger[]::new),
127
-                        new int[]{ 2, 0, 1, 3, 4, 5, 6 }));
128
+                        new int[] { 2, 0, 1, 3, 4, 5, 6 }));
128 129
 
129 130
         // Queue with 13 elements.
130 131
         objects.add(new TestParameters<>(
131
-                Arrays.stream(new int[]{ 1, 7, 2, 8, 9, 3, 4, 10, 11, 12, 13, 5, 6 })
132
+                Arrays.stream(new int[] { 1, 7, 2, 8, 9, 3, 4, 10, 11, 12, 13, 5, 6 })
132 133
                         .mapToObj(MutableInteger::new).toArray(MutableInteger[]::new),
133
-                new int[]{ 3, 4, 0, 2, 5, 6, 1, 7, 8, 9, 10, 11, 12 }));
134
+                new int[] { 3, 4, 0, 2, 5, 6, 1, 7, 8, 9, 10, 11, 12 }));
134 135
 
135 136
         return objects;
136 137
     }
@@ -200,7 +201,7 @@ public abstract class PriorityQueueTest {
200 201
     @Test
201 202
     public void testDeleteMin() {
202 203
         int size = parameters.data.length;
203
-        assertEquals(queue.size(), size);
204
+        assertEquals(size, queue.size());
204 205
         MutableInteger[] range = Arrays.copyOf(parameters.data, parameters.data.length);
205 206
         Arrays.sort(range);
206 207
         for (MutableInteger x: range) {
@@ -229,14 +230,14 @@ public abstract class PriorityQueueTest {
229 230
             fail("Expected exception " + ElementNotFoundException.class.getName());
230 231
         }
231 232
         catch (ElementNotFoundException e) {
232
-            assertEquals(e.getElement(), min);
233
+            assertEquals(min, e.getElement());
233 234
         }
234 235
         try {
235 236
             queue.remove(max);
236 237
             fail("Expected exception " + ElementNotFoundException.class.getName());
237 238
         }
238 239
         catch (ElementNotFoundException e) {
239
-            assertEquals(e.getElement(), max);
240
+            assertEquals(max, e.getElement());
240 241
         }
241 242
     }
242 243
 
@@ -250,7 +251,7 @@ public abstract class PriorityQueueTest {
250 251
                 fail("Expected exception " + ElementNotFoundException.class.getName());
251 252
             }
252 253
             catch (ElementNotFoundException e) {
253
-                assertEquals(e.getElement(), min);
254
+                assertEquals(min, e.getElement());
254 255
             }
255 256
         }
256 257
     }
@@ -266,7 +267,7 @@ public abstract class PriorityQueueTest {
266 267
                 fail("Expected exception " + ElementNotFoundException.class.getName());
267 268
             }
268 269
             catch (ElementNotFoundException e) {
269
-                assertEquals(e.getElement(), data);
270
+                assertEquals(data, e.getElement());
270 271
             }
271 272
         }
272 273
     }

+ 20
- 20
src/test/org/insa/graph/GraphTest.java View File

@@ -83,26 +83,26 @@ public class GraphTest {
83 83
             assertEquals(expNbSucc[i], transpose.get(i).getNumberOfSuccessors());
84 84
         }
85 85
 
86
-        assertEquals(getArcsBetween(transpose.get(0), transpose.get(1)).size(), 1);
87
-        assertEquals(getArcsBetween(transpose.get(0), transpose.get(2)).size(), 1);
88
-        assertEquals(getArcsBetween(transpose.get(0), transpose.get(3)).size(), 1);
89
-        assertEquals(getArcsBetween(transpose.get(0), transpose.get(4)).size(), 1);
90
-        assertEquals(getArcsBetween(transpose.get(1), transpose.get(0)).size(), 1);
91
-        assertEquals(getArcsBetween(transpose.get(1), transpose.get(2)).size(), 1);
92
-        assertEquals(getArcsBetween(transpose.get(1), transpose.get(3)).size(), 0);
93
-        assertEquals(getArcsBetween(transpose.get(1), transpose.get(4)).size(), 0);
94
-        assertEquals(getArcsBetween(transpose.get(2), transpose.get(0)).size(), 1);
95
-        assertEquals(getArcsBetween(transpose.get(2), transpose.get(1)).size(), 1);
96
-        assertEquals(getArcsBetween(transpose.get(2), transpose.get(3)).size(), 0);
97
-        assertEquals(getArcsBetween(transpose.get(2), transpose.get(4)).size(), 0);
98
-        assertEquals(getArcsBetween(transpose.get(3), transpose.get(0)).size(), 1);
99
-        assertEquals(getArcsBetween(transpose.get(3), transpose.get(1)).size(), 0);
100
-        assertEquals(getArcsBetween(transpose.get(3), transpose.get(2)).size(), 3);
101
-        assertEquals(getArcsBetween(transpose.get(3), transpose.get(4)).size(), 0);
102
-        assertEquals(getArcsBetween(transpose.get(4), transpose.get(0)).size(), 1);
103
-        assertEquals(getArcsBetween(transpose.get(4), transpose.get(1)).size(), 0);
104
-        assertEquals(getArcsBetween(transpose.get(4), transpose.get(2)).size(), 0);
105
-        assertEquals(getArcsBetween(transpose.get(4), transpose.get(3)).size(), 1);
86
+        assertEquals(1, getArcsBetween(transpose.get(0), transpose.get(1)).size());
87
+        assertEquals(1, getArcsBetween(transpose.get(0), transpose.get(2)).size());
88
+        assertEquals(1, getArcsBetween(transpose.get(0), transpose.get(3)).size());
89
+        assertEquals(1, getArcsBetween(transpose.get(0), transpose.get(4)).size());
90
+        assertEquals(1, getArcsBetween(transpose.get(1), transpose.get(0)).size());
91
+        assertEquals(1, getArcsBetween(transpose.get(1), transpose.get(2)).size());
92
+        assertEquals(0, getArcsBetween(transpose.get(1), transpose.get(3)).size());
93
+        assertEquals(0, getArcsBetween(transpose.get(1), transpose.get(4)).size());
94
+        assertEquals(1, getArcsBetween(transpose.get(2), transpose.get(0)).size());
95
+        assertEquals(1, getArcsBetween(transpose.get(2), transpose.get(1)).size());
96
+        assertEquals(0, getArcsBetween(transpose.get(2), transpose.get(3)).size());
97
+        assertEquals(0, getArcsBetween(transpose.get(2), transpose.get(4)).size());
98
+        assertEquals(1, getArcsBetween(transpose.get(3), transpose.get(0)).size());
99
+        assertEquals(0, getArcsBetween(transpose.get(3), transpose.get(1)).size());
100
+        assertEquals(3, getArcsBetween(transpose.get(3), transpose.get(2)).size());
101
+        assertEquals(0, getArcsBetween(transpose.get(3), transpose.get(4)).size());
102
+        assertEquals(1, getArcsBetween(transpose.get(4), transpose.get(0)).size());
103
+        assertEquals(0, getArcsBetween(transpose.get(4), transpose.get(1)).size());
104
+        assertEquals(0, getArcsBetween(transpose.get(4), transpose.get(2)).size());
105
+        assertEquals(1, getArcsBetween(transpose.get(4), transpose.get(3)).size());
106 106
 
107 107
     }
108 108
 }

+ 4
- 4
src/test/org/insa/graph/NodeTest.java View File

@@ -65,18 +65,18 @@ public class NodeTest {
65 65
     @Test
66 66
     public void testGetNumberOfSuccessors() {
67 67
         final int[] expNbSucc = { 4, 2, 5, 2, 1, 0 };
68
-        assertEquals(nodes.length, expNbSucc.length);
68
+        assertEquals(expNbSucc.length, nodes.length);
69 69
         for (int i = 0; i < expNbSucc.length; ++i) {
70
-            assertEquals(nodes[i].getNumberOfSuccessors(), expNbSucc[i]);
70
+            assertEquals(expNbSucc[i], nodes[i].getNumberOfSuccessors());
71 71
         }
72 72
     }
73 73
 
74 74
     @Test
75 75
     public void testHasSuccessors() {
76 76
         final int[] expNbSucc = { 4, 2, 5, 2, 1, 0 };
77
-        assertEquals(nodes.length, expNbSucc.length);
77
+        assertEquals(expNbSucc.length, nodes.length);
78 78
         for (int i = 0; i < expNbSucc.length; ++i) {
79
-            assertEquals(nodes[i].hasSuccessors(), expNbSucc[i] != 0);
79
+            assertEquals(expNbSucc[i] != 0, nodes[i].hasSuccessors());
80 80
         }
81 81
     }
82 82
 

+ 39
- 39
src/test/org/insa/graph/PathTest.java View File

@@ -93,15 +93,15 @@ public class PathTest {
93 93
         assertFalse(longLoopPath.isEmpty());
94 94
         assertFalse(invalidPath.isEmpty());
95 95
     }
96
-    
96
+
97 97
     @Test
98 98
     public void testSize() {
99
-        assertEquals(emptyPath.size(), 0);
100
-        assertEquals(singleNodePath.size(), 1);
101
-        assertEquals(shortPath.size(), 4);
102
-        assertEquals(longPath.size(), 5);
103
-        assertEquals(loopPath.size(), 5);
104
-        assertEquals(longLoopPath.size(), 10);
99
+        assertEquals(0, emptyPath.size());
100
+        assertEquals(1, singleNodePath.size());
101
+        assertEquals(4, shortPath.size());
102
+        assertEquals(5, longPath.size());
103
+        assertEquals(5, loopPath.size());
104
+        assertEquals(10, longLoopPath.size());
105 105
     }
106 106
 
107 107
     @Test
@@ -118,41 +118,41 @@ public class PathTest {
118 118
 
119 119
     @Test
120 120
     public void testGetLength() {
121
-        assertEquals(emptyPath.getLength(), 0, 1e-6);
122
-        assertEquals(singleNodePath.getLength(), 0, 1e-6);
123
-        assertEquals(shortPath.getLength(), 40, 1e-6);
124
-        assertEquals(longPath.getLength(), 62.8, 1e-6);
125
-        assertEquals(loopPath.getLength(), 55, 1e-6);
126
-        assertEquals(longLoopPath.getLength(), 120, 1e-6);
121
+        assertEquals(0, emptyPath.getLength(), 1e-6);
122
+        assertEquals(0, singleNodePath.getLength(), 1e-6);
123
+        assertEquals(40, shortPath.getLength(), 1e-6);
124
+        assertEquals(62.8, longPath.getLength(), 1e-6);
125
+        assertEquals(55, loopPath.getLength(), 1e-6);
126
+        assertEquals(120, longLoopPath.getLength(), 1e-6);
127 127
     }
128 128
 
129 129
     @Test
130 130
     public void testGetTravelTime() {
131 131
         // Note: 18 km/h = 5m/s
132
-        assertEquals(emptyPath.getTravelTime(18), 0, 1e-6);
133
-        assertEquals(singleNodePath.getTravelTime(18), 0, 1e-6);
134
-        assertEquals(shortPath.getTravelTime(18), 8, 1e-6);
135
-        assertEquals(longPath.getTravelTime(18), 12.56, 1e-6);
136
-        assertEquals(loopPath.getTravelTime(18), 11, 1e-6);
137
-        assertEquals(longLoopPath.getTravelTime(18), 24, 1e-6);
132
+        assertEquals(0, emptyPath.getTravelTime(18), 1e-6);
133
+        assertEquals(0, singleNodePath.getTravelTime(18), 1e-6);
134
+        assertEquals(8, shortPath.getTravelTime(18), 1e-6);
135
+        assertEquals(12.56, longPath.getTravelTime(18), 1e-6);
136
+        assertEquals(11, loopPath.getTravelTime(18), 1e-6);
137
+        assertEquals(24, longLoopPath.getTravelTime(18), 1e-6);
138 138
 
139 139
         // Note: 28.8 km/h = 8m/s
140
-        assertEquals(emptyPath.getTravelTime(28.8), 0, 1e-6);
141
-        assertEquals(singleNodePath.getTravelTime(28.8), 0, 1e-6);
142
-        assertEquals(shortPath.getTravelTime(28.8), 5, 1e-6);
143
-        assertEquals(longPath.getTravelTime(28.8), 7.85, 1e-6);
144
-        assertEquals(loopPath.getTravelTime(28.8), 6.875, 1e-6);
145
-        assertEquals(longLoopPath.getTravelTime(28.8), 15, 1e-6);
140
+        assertEquals(0, emptyPath.getTravelTime(28.8), 1e-6);
141
+        assertEquals(0, singleNodePath.getTravelTime(28.8), 1e-6);
142
+        assertEquals(5, shortPath.getTravelTime(28.8), 1e-6);
143
+        assertEquals(7.85, longPath.getTravelTime(28.8), 1e-6);
144
+        assertEquals(6.875, loopPath.getTravelTime(28.8), 1e-6);
145
+        assertEquals(15, longLoopPath.getTravelTime(28.8), 1e-6);
146 146
     }
147 147
 
148 148
     @Test
149 149
     public void testGetMinimumTravelTime() {
150
-        assertEquals(emptyPath.getMinimumTravelTime(), 0, 1e-4);
151
-        assertEquals(singleNodePath.getLength(), 0, 1e-4);
152
-        assertEquals(shortPath.getMinimumTravelTime(), 4, 1e-4);
153
-        assertEquals(longPath.getMinimumTravelTime(), 5.14, 1e-4);
154
-        assertEquals(loopPath.getMinimumTravelTime(), 5.5, 1e-4);
155
-        assertEquals(longLoopPath.getMinimumTravelTime(), 11.25, 1e-4);
150
+        assertEquals(0, emptyPath.getMinimumTravelTime(), 1e-4);
151
+        assertEquals(0, singleNodePath.getLength(), 1e-4);
152
+        assertEquals(4, shortPath.getMinimumTravelTime(), 1e-4);
153
+        assertEquals(5.14, longPath.getMinimumTravelTime(), 1e-4);
154
+        assertEquals(5.5, loopPath.getMinimumTravelTime(), 1e-4);
155
+        assertEquals(11.25, longLoopPath.getMinimumTravelTime(), 1e-4);
156 156
     }
157 157
 
158 158
     @Test
@@ -180,13 +180,13 @@ public class PathTest {
180 180
 
181 181
         // Trap construction!
182 182
         path = Path.createFastestPathFromNodes(graph, Arrays.asList(new Node[] { nodes[1] }));
183
-        assertEquals(path.getOrigin(), nodes[1]);
184
-        assertEquals(path.getArcs().size(), 0);
183
+        assertEquals(nodes[1], path.getOrigin());
184
+        assertEquals(0, path.getArcs().size());
185 185
 
186 186
         // Trap construction - The return!
187 187
         path = Path.createFastestPathFromNodes(graph, Arrays.asList(new Node[0]));
188
-        assertEquals(path.getOrigin(), null);
189
-        assertEquals(path.getArcs().size(), 0);
188
+        assertEquals(null, path.getOrigin());
189
+        assertEquals(0, path.getArcs().size());
190 190
         assertTrue(path.isEmpty());
191 191
     }
192 192
 
@@ -215,13 +215,13 @@ public class PathTest {
215 215
 
216 216
         // Trap construction!
217 217
         path = Path.createShortestPathFromNodes(graph, Arrays.asList(new Node[] { nodes[1] }));
218
-        assertEquals(path.getOrigin(), nodes[1]);
219
-        assertEquals(path.getArcs().size(), 0);
218
+        assertEquals(nodes[1], path.getOrigin());
219
+        assertEquals(0, path.getArcs().size());
220 220
 
221 221
         // Trap construction - The return!
222 222
         path = Path.createShortestPathFromNodes(graph, Arrays.asList(new Node[0]));
223
-        assertEquals(path.getOrigin(), null);
224
-        assertEquals(path.getArcs().size(), 0);
223
+        assertEquals(null, path.getOrigin());
224
+        assertEquals(0, path.getArcs().size());
225 225
         assertTrue(path.isEmpty());
226 226
     }
227 227
 

Loading…
Cancel
Save