Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @org.junit.Test(timeout = 15000)
- @jug.TestName("WeightedSmallLabyrinth.txt: dfsPath( (3,3), (1,0) ) returns correct path")
- public void Test4() throws Throwable {
- TARGET = new Labyrinth("WeightedSmallLabyrinth.txt");
- Walkway[] lWalkways = {
- new Walkway("(3,3)(2,3)", 2),
- new Walkway("(2,3)(2,2)", 2),
- new Walkway("(2,2)(2,1)", 20),
- new Walkway("(2,1)(2,0)", 2),
- new Walkway("(2,0)(1,0)", 2),
- };
- Iterable<Edge<Walkway>> pathIterable = TARGET.dfsPath(new RoomCoordinate(3, 3), new RoomCoordinate(1, 0));
- LinkedList<Edge<Walkway>> lPath = Util.toList(pathIterable);
- Edge<Walkway> lEdge = null;
- int lCorrectEdges = 0;
- int lCurrentEdge = 0;
- while(!(lPath.isEmpty())){
- lEdge = lPath.removeFirst();
- String lEdgeName = lEdge.getElement().getName();
- String lVertexName1 = lEdgeName.substring(0, lEdgeName.indexOf(")") + 1);
- String lVertexName2 = lEdgeName.substring(lEdgeName.indexOf(")") + 1);
- String lPossibleEdge1 = lVertexName1 + lVertexName2;
- String lPossibleEdge2 = lVertexName2 + lVertexName1;
- String lActualEdgeString = lWalkways[lCurrentEdge].getName();
- if(lActualEdgeString.equals(lPossibleEdge1) || lActualEdgeString.equals(lPossibleEdge2)){
- lCorrectEdges++;
- }
- lCurrentEdge++;
- }
- org.junit.Assert.assertEquals("WeightedSmallLabyrinth.txt: dfsPath( (3,3), (1,0) ) returns correct path",
- (Object) (5), (Object) (lCorrectEdges));
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement