Browse Source

Fix issue with path test.

Mikael Capelle 6 years ago
parent
commit
a765e58f84
1 changed files with 27 additions and 27 deletions
  1. 27
    27
      src/test/org/insa/graph/PathTest.java

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

@@ -22,7 +22,7 @@ public class PathTest {
22 22
 
23 23
     // List of arcs in the graph, a2b is the arc from node A (0) to B (1).
24 24
     @SuppressWarnings("unused")
25
-    private static ArcForward a2b, a2c, a2e, b2c, c2d_1, c2d_2, c2d_3, c2a, d2a, d2e, e2d;
25
+    private static Arc a2b, a2c, a2e, b2c, c2d_1, c2d_2, c2d_3, c2a, d2a, d2e, e2d;
26 26
 
27 27
     // Some paths...
28 28
     private static Path emptyPath, shortPath, longPath, loopPath, longLoopPath, invalidPath;
@@ -41,26 +41,26 @@ public class PathTest {
41 41
         }
42 42
 
43 43
         // Add arcs...
44
-        a2b = new ArcForward(nodes[0], nodes[1], 10, speed10, null);
45
-        a2c = new ArcForward(nodes[0], nodes[2], 15, speed10, null);
46
-        a2e = new ArcForward(nodes[0], nodes[4], 15, speed20, null);
47
-        b2c = new ArcForward(nodes[1], nodes[2], 10, speed10, null);
48
-        c2d_1 = new ArcForward(nodes[2], nodes[3], 20, speed10, null);
49
-        c2d_2 = new ArcForward(nodes[2], nodes[3], 10, speed10, null);
50
-        c2d_3 = new ArcForward(nodes[2], nodes[3], 15, speed20, null);
51
-        d2a = new ArcForward(nodes[3], nodes[0], 15, speed10, null);
52
-        d2e = new ArcForward(nodes[3], nodes[4], 20, speed20, null);
53
-        e2d = new ArcForward(nodes[4], nodes[0], 10, speed10, null);
44
+        a2b = Node.linkNodes(nodes[0], nodes[1], 10, speed10, null);
45
+        a2c = Node.linkNodes(nodes[0], nodes[2], 15, speed10, null);
46
+        a2e = Node.linkNodes(nodes[0], nodes[4], 15, speed20, null);
47
+        b2c = Node.linkNodes(nodes[1], nodes[2], 10, speed10, null);
48
+        c2d_1 = Node.linkNodes(nodes[2], nodes[3], 20, speed10, null);
49
+        c2d_2 = Node.linkNodes(nodes[2], nodes[3], 10, speed10, null);
50
+        c2d_3 = Node.linkNodes(nodes[2], nodes[3], 15, speed20, null);
51
+        d2a = Node.linkNodes(nodes[3], nodes[0], 15, speed10, null);
52
+        d2e = Node.linkNodes(nodes[3], nodes[4], 20, speed20, null);
53
+        e2d = Node.linkNodes(nodes[4], nodes[0], 10, speed10, null);
54 54
 
55 55
         graph = new Graph("ID", "", Arrays.asList(nodes), null);
56 56
 
57 57
         emptyPath = new Path(graph, new ArrayList<Arc>());
58
-        shortPath = new Path(graph, Arrays.asList(new ArcForward[]{ a2b, b2c, c2d_1 }));
59
-        longPath = new Path(graph, Arrays.asList(new ArcForward[]{ a2b, b2c, c2d_1, d2e }));
60
-        loopPath = new Path(graph, Arrays.asList(new ArcForward[]{ a2b, b2c, c2d_1, d2a }));
58
+        shortPath = new Path(graph, Arrays.asList(new Arc[]{ a2b, b2c, c2d_1 }));
59
+        longPath = new Path(graph, Arrays.asList(new Arc[]{ a2b, b2c, c2d_1, d2e }));
60
+        loopPath = new Path(graph, Arrays.asList(new Arc[]{ a2b, b2c, c2d_1, d2a }));
61 61
         longLoopPath = new Path(graph,
62
-                Arrays.asList(new ArcForward[]{ a2b, b2c, c2d_1, d2a, a2c, c2d_3, d2a, a2b, b2c }));
63
-        invalidPath = new Path(graph, Arrays.asList(new ArcForward[]{ a2b, c2d_1, d2e }));
62
+                Arrays.asList(new Arc[]{ a2b, b2c, c2d_1, d2a, a2c, c2d_3, d2a, a2b, b2c }));
63
+        invalidPath = new Path(graph, Arrays.asList(new Arc[]{ a2b, c2d_1, d2e }));
64 64
 
65 65
     }
66 66
 
@@ -103,11 +103,11 @@ public class PathTest {
103 103
 
104 104
     @Test
105 105
     public void testGetLength() {
106
-        assertEquals(emptyPath.getLength(), 0);
107
-        assertEquals(shortPath.getLength(), 40);
108
-        assertEquals(longPath.getLength(), 60);
109
-        assertEquals(loopPath.getLength(), 55);
110
-        assertEquals(longLoopPath.getLength(), 120);
106
+        assertEquals(emptyPath.getLength(), 0, 1e-6);
107
+        assertEquals(shortPath.getLength(), 40, 1e-6);
108
+        assertEquals(longPath.getLength(), 60, 1e-6);
109
+        assertEquals(loopPath.getLength(), 55, 1e-6);
110
+        assertEquals(longLoopPath.getLength(), 120, 1e-6);
111 111
     }
112 112
 
113 113
     @Test
@@ -122,12 +122,12 @@ public class PathTest {
122 122
     @Test
123 123
     public void testCreateFastestPathFromNodes() {
124 124
         Path path;
125
-        ArcForward[] expected;
125
+        Arc[] expected;
126 126
 
127 127
         // Simple construction
128 128
         path = Path.createFastestPathFromNodes(graph,
129 129
                 Arrays.asList(new Node[]{ nodes[0], nodes[1], nodes[2] }));
130
-        expected = new ArcForward[]{ a2b, b2c };
130
+        expected = new Arc[]{ a2b, b2c };
131 131
         assertEquals(expected.length, path.getArcs().size());
132 132
         for (int i = 0; i < expected.length; ++i) {
133 133
             assertEquals(expected[i], path.getArcs().get(i));
@@ -136,7 +136,7 @@ public class PathTest {
136 136
         // Not so simple construction
137 137
         path = Path.createFastestPathFromNodes(graph,
138 138
                 Arrays.asList(new Node[]{ nodes[0], nodes[1], nodes[2], nodes[3] }));
139
-        expected = new ArcForward[]{ a2b, b2c, c2d_3 };
139
+        expected = new Arc[]{ a2b, b2c, c2d_3 };
140 140
         assertEquals(expected.length, path.getArcs().size());
141 141
         for (int i = 0; i < expected.length; ++i) {
142 142
             assertEquals(expected[i], path.getArcs().get(i));
@@ -146,12 +146,12 @@ public class PathTest {
146 146
     @Test
147 147
     public void testCreateShortestPathFromNodes() {
148 148
         Path path;
149
-        ArcForward[] expected;
149
+        Arc[] expected;
150 150
 
151 151
         // Simple construction
152 152
         path = Path.createShortestPathFromNodes(graph,
153 153
                 Arrays.asList(new Node[]{ nodes[0], nodes[1], nodes[2] }));
154
-        expected = new ArcForward[]{ a2b, b2c };
154
+        expected = new Arc[]{ a2b, b2c };
155 155
         assertEquals(expected.length, path.getArcs().size());
156 156
         for (int i = 0; i < expected.length; ++i) {
157 157
             assertEquals(expected[i], path.getArcs().get(i));
@@ -160,7 +160,7 @@ public class PathTest {
160 160
         // Not so simple construction
161 161
         path = Path.createShortestPathFromNodes(graph,
162 162
                 Arrays.asList(new Node[]{ nodes[0], nodes[1], nodes[2], nodes[3] }));
163
-        expected = new ArcForward[]{ a2b, b2c, c2d_2 };
163
+        expected = new Arc[]{ a2b, b2c, c2d_2 };
164 164
         assertEquals(expected.length, path.getArcs().size());
165 165
         for (int i = 0; i < expected.length; ++i) {
166 166
             assertEquals(expected[i], path.getArcs().get(i));

Loading…
Cancel
Save