plus de data pour junit
This commit is contained in:
parent
d1acc6cdf5
commit
442a06e0e8
2 changed files with 48 additions and 74 deletions
|
@ -20,7 +20,7 @@ public class ArcInspectorFactory {
|
||||||
|
|
||||||
// Common filters:
|
// Common filters:
|
||||||
|
|
||||||
// No filter (all arcs allowed):
|
// No filter (all arcs allowed), shortest:
|
||||||
filters.add(new ArcInspector() {
|
filters.add(new ArcInspector() {
|
||||||
@Override
|
@Override
|
||||||
public boolean isAllowed(Arc arc) {
|
public boolean isAllowed(Arc arc) {
|
||||||
|
@ -78,7 +78,7 @@ public class ArcInspectorFactory {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// Only road allowed for cars and time:
|
// All allowed and time?
|
||||||
|
|
||||||
filters.add(new ArcInspector() {
|
filters.add(new ArcInspector() {
|
||||||
@Override
|
@Override
|
||||||
|
@ -107,7 +107,7 @@ public class ArcInspectorFactory {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
filters.add(new ArcInspector() {
|
filters.add(new ArcInspector() {// *this one* seems to be fastest path with car
|
||||||
@Override
|
@Override
|
||||||
public boolean isAllowed(Arc arc) {
|
public boolean isAllowed(Arc arc) {
|
||||||
return arc.getRoadInformation().getAccessRestrictions()
|
return arc.getRoadInformation().getAccessRestrictions()
|
||||||
|
|
|
@ -32,9 +32,18 @@ public class DijkstraAlgorithmTest{
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
private static Arc a2b, a2c, a2e, b2c, c2d_1, c2d_2, c2d_3, c2a, d2a, d2e, e2d;
|
private static Arc a2b, a2c, a2e, b2c, c2d_1, c2d_2, c2d_3, c2a, d2a, d2e, e2d;
|
||||||
|
|
||||||
// Some paths...
|
private static ShortestPathData dataal, datacl, dataat, datact, datapt, onenodata, emptydata, invalidata;
|
||||||
private static Path emptyPath, singleNodePath, shortPath, longPath, loopPath, longLoopPath,
|
|
||||||
invalidPath;
|
// permet de savoir quels arcs autoriser(cf l.187 excel ggdoc)
|
||||||
|
private static ArcInspector alllen = ArcInspectorFactory.getAllFilters().get(0);
|
||||||
|
private static ArcInspector carlen = ArcInspectorFactory.getAllFilters().get(1);
|
||||||
|
private static ArcInspector alltime = ArcInspectorFactory.getAllFilters().get(2);
|
||||||
|
private static ArcInspector cartime = ArcInspectorFactory.getAllFilters().get(3);
|
||||||
|
private static ArcInspector pietime = ArcInspectorFactory.getAllFilters().get(4);
|
||||||
|
|
||||||
|
private static DijkstraAlgorithm dijkal, dijkcl, dijkat, dijkct, dijkpt, onenodijk, emptydijk, invalidijk;
|
||||||
|
private static BellmanFordAlgorithm bfaal, bfacl, bfaat, bfact, bfapt;
|
||||||
|
|
||||||
|
|
||||||
@BeforeClass
|
@BeforeClass
|
||||||
public static void initAll() throws IOException {
|
public static void initAll() throws IOException {
|
||||||
|
@ -63,52 +72,38 @@ public class DijkstraAlgorithmTest{
|
||||||
|
|
||||||
graph = new Graph("ID", "", Arrays.asList(nodes), null);
|
graph = new Graph("ID", "", Arrays.asList(nodes), null);
|
||||||
|
|
||||||
emptyPath = new Path(graph, new ArrayList<Arc>());
|
//initialisation des datas
|
||||||
singleNodePath = new Path(graph, nodes[1]);
|
dataal= new ShortestPathData(graph, null, null, alllen);
|
||||||
shortPath = new Path(graph, Arrays.asList(new Arc[] { a2b, b2c, c2d_1 }));
|
datacl= new ShortestPathData(graph, null, null, carlen);
|
||||||
longPath = new Path(graph, Arrays.asList(new Arc[] { a2b, b2c, c2d_1, d2e }));
|
dataat= new ShortestPathData(graph, null, null, alltime);
|
||||||
loopPath = new Path(graph, Arrays.asList(new Arc[] { a2b, b2c, c2d_1, d2a }));
|
datact= new ShortestPathData(graph, null, null, cartime);
|
||||||
longLoopPath = new Path(graph,
|
datapt= new ShortestPathData(graph, null, null, pietime);
|
||||||
Arrays.asList(new Arc[] { a2b, b2c, c2d_1, d2a, a2c, c2d_3, d2a, a2b, b2c }));
|
onenodata=new ShortestPathData(graph, nodes[2], nodes[2], pietime);
|
||||||
invalidPath = new Path(graph, Arrays.asList(new Arc[] { a2b, c2d_1, d2e }));
|
emptydata=new ShortestPathData(graph, null, null, pietime);
|
||||||
|
invalidata=new ShortestPathData(graph, null, null, pietime);
|
||||||
|
|
||||||
|
//initialisation des Dijkstras
|
||||||
|
dijkal=new DijkstraAlgorithm(dataal);
|
||||||
|
dijkcl=new DijkstraAlgorithm(datacl);
|
||||||
|
dijkat=new DijkstraAlgorithm(dataat);
|
||||||
|
dijkct=new DijkstraAlgorithm(datact);
|
||||||
|
dijkpt=new DijkstraAlgorithm(datapt);
|
||||||
|
onenodijk=new DijkstraAlgorithm(onenodata);
|
||||||
|
emptydijk=new DijkstraAlgorithm(emptydata);
|
||||||
|
invalidijk=new DijkstraAlgorithm(invalidata);
|
||||||
|
|
||||||
|
//initialisation des Bellman-Ford pour comparaison
|
||||||
|
bfaal=new BellmanFordAlgorithm(dataal);
|
||||||
|
bfacl=new BellmanFordAlgorithm(datacl);
|
||||||
|
bfaat=new BellmanFordAlgorithm(dataat);
|
||||||
|
bfact=new BellmanFordAlgorithm(datact);
|
||||||
|
bfapt=new BellmanFordAlgorithm(datapt);
|
||||||
|
|
||||||
}
|
}
|
||||||
//---fin de la copie de PathTest.java
|
|
||||||
|
|
||||||
//regarder LAUNCH.JAVA pour ouvrir une map
|
|
||||||
|
|
||||||
private static DijkstraAlgorithm samenode, bikinsatime, bikinsalong, invalinsa;
|
|
||||||
private static BellmanFordAlgorithm Bsamenode, Bbikinsatime, Bbikinsalong, Binvalinsa;
|
|
||||||
private static ShortestPathData samenodespd, bikinsatimespd, bikinsalongspd, invalinsaspd;
|
|
||||||
|
|
||||||
// (cf l.187 excel ggdoc) permet de savoir quels arcs autoriser
|
|
||||||
private ArcInspector inspecteuruno=ArcInspectorFactory.getAllFilters().get(0);// No filter (all arcs allowed)
|
|
||||||
private ArcInspector inspecteurtres=ArcInspectorFactory.getAllFilters().get(2);// Only road allowed for cars and time
|
|
||||||
|
|
||||||
|
|
||||||
//créer plus et avec des maps différentes
|
//créer plus et avec des maps différentes
|
||||||
//faire des test spécifiques pour longs trajets
|
//faire des test spécifiques pour longs trajets
|
||||||
|
|
||||||
/*@BeforeClass
|
|
||||||
public static void initAllbis() {
|
|
||||||
//en fait pas sûr que ça marche comme ça, voir avec Launch
|
|
||||||
samenodespd=new ShortestPathData(graph, null, null, null);
|
|
||||||
bikinsatimespd=new ShortestPathData(graph, null, null, null);
|
|
||||||
bikinsalongspd=new ShortestPathData(graph, null, null, null);
|
|
||||||
invalinsaspd=new ShortestPathData(graph, null, null, null);
|
|
||||||
|
|
||||||
samenode=new DijkstraAlgorithm(samenodespd);
|
|
||||||
bikinsatime=new DijkstraAlgorithm(bikinsatimespd);
|
|
||||||
bikinsalong=new DijkstraAlgorithm(bikinsalongspd);
|
|
||||||
invalinsa=new DijkstraAlgorithm(invalinsaspd);
|
|
||||||
//est-ce que c'est vraiment la bonne manière de faire? car alors très long de rajouter des path à tester
|
|
||||||
Bsamenode=new BellmanFordAlgorithm(samenodespd);
|
|
||||||
Bbikinsatime= new BellmanFordAlgorithm(bikinsatimespd);
|
|
||||||
Bbikinsalong=new BellmanFordAlgorithm(bikinsalongspd);
|
|
||||||
Binvalinsa=new BellmanFordAlgorithm(invalinsaspd);
|
|
||||||
}*/
|
|
||||||
|
|
||||||
//comment trouver les noeuds dans une map? Ne comparer que les grands chemins (qui font ouvrir la map) avec BF
|
|
||||||
|
|
||||||
/*(Test faits directement via la console et DijkstraAlgorithm.java, actuellement commentés:
|
/*(Test faits directement via la console et DijkstraAlgorithm.java, actuellement commentés:
|
||||||
-coûts croissants
|
-coûts croissants
|
||||||
|
@ -117,44 +112,23 @@ public class DijkstraAlgorithmTest{
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void cheminValide() {
|
public void cheminValide() {
|
||||||
ShortestPathData data1=new ShortestPathData(null, null, null, inspecteuruno);
|
assertTrue(dijkal.doRun().getPath().isValid());
|
||||||
ShortestPathData data3=new ShortestPathData(null, null, null, inspecteurtres);
|
|
||||||
ShortestPathAlgorithm Dijkstra1=new DijkstraAlgorithm(data1);
|
|
||||||
ShortestPathAlgorithm Dijkstra3=new DijkstraAlgorithm(data3);
|
|
||||||
assertTrue(Dijkstra1.doRun().getPath().isValid());
|
|
||||||
assertTrue(Dijkstra3.doRun().getPath().isValid());
|
|
||||||
assertTrue(samenode.doRun().getPath().isValid());
|
|
||||||
assertTrue(bikinsatime.doRun().getPath().isValid());
|
|
||||||
assertTrue(bikinsalong.doRun().getPath().isValid());
|
|
||||||
assertFalse(invalinsa.doRun().getPath().isValid());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void faisable() {
|
public void faisable() {
|
||||||
ShortestPathData data1=new ShortestPathData(null, null, null, inspecteuruno);
|
assertTrue(dijkal.doRun().isFeasible());
|
||||||
ShortestPathData data3=new ShortestPathData(null, null, null, inspecteurtres);
|
|
||||||
ShortestPathAlgorithm Dijkstra1=new DijkstraAlgorithm(data1);
|
|
||||||
ShortestPathAlgorithm Dijkstra3=new DijkstraAlgorithm(data3);
|
|
||||||
assertTrue(Dijkstra1.doRun().isFeasible());
|
|
||||||
assertTrue(Dijkstra3.doRun().isFeasible());
|
|
||||||
assertTrue(samenode.doRun().isFeasible());
|
|
||||||
assertTrue(bikinsatime.doRun().isFeasible());
|
|
||||||
assertTrue(bikinsalong.doRun().isFeasible());
|
|
||||||
assertFalse(invalinsa.doRun().isFeasible());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//résultat identique à Bellman-Ford (sur les petits scénarios)
|
//résultat identique à Bellman-Ford (sur les petits scénarios)
|
||||||
@Test
|
@Test
|
||||||
public void sameasBF() {
|
public void sameasBF() {
|
||||||
assertTrue(samenode.doRun().getPath().equals(Bsamenode.doRun().getPath()));
|
assertTrue(Float.compare(dijkal.doRun().getPath().getLength(),bfaal.doRun().getPath().getLength())==0);
|
||||||
assertTrue(bikinsatime.doRun().getPath().equals(Bbikinsatime.doRun().getPath()));
|
|
||||||
assertTrue(bikinsalong.doRun().getPath().equals(Bbikinsalong.doRun().getPath()));
|
|
||||||
assertTrue(invalinsa.doRun().getPath().equals(Binvalinsa.doRun().getPath()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//tests applicables aussi pour des grands scénarios:
|
//tests applicables aussi pour des grands scénarios:
|
||||||
//...
|
//...
|
||||||
|
|
||||||
|
//graph = new BinaryGraphReader(new DataInputStream(new BufferedInputStream(new FileInputStream("a")))).read;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue