Advertisement
Guest User

Untitled

a guest
Apr 14th, 2016
664
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.52 KB | None | 0 0
  1. @org.junit.Test(timeout = 15000)
  2. @jug.TestName("WeightedSmallLabyrinth.txt: dfsPath( (3,3), (1,0) ) returns correct path")
  3. public void Test4() throws Throwable {
  4.     TARGET = new Labyrinth("WeightedSmallLabyrinth.txt");
  5.     Walkway[] lWalkways = {
  6.         new Walkway("(3,3)(2,3)", 2),
  7.         new Walkway("(2,3)(2,2)", 2),
  8.         new Walkway("(2,2)(2,1)", 20),
  9.         new Walkway("(2,1)(2,0)", 2),
  10.         new Walkway("(2,0)(1,0)", 2),
  11.     };
  12.     Iterable<Edge<Walkway>> pathIterable = TARGET.dfsPath(new RoomCoordinate(3, 3), new RoomCoordinate(1, 0));
  13.     LinkedList<Edge<Walkway>> lPath = Util.toList(pathIterable);
  14.     Edge<Walkway> lEdge = null;
  15.     int lCorrectEdges = 0;
  16.     int lCurrentEdge = 0;
  17.     while(!(lPath.isEmpty())){
  18.         lEdge = lPath.removeFirst();
  19.         String lEdgeName = lEdge.getElement().getName();
  20.         String lVertexName1 = lEdgeName.substring(0, lEdgeName.indexOf(")") + 1);
  21.         String lVertexName2 = lEdgeName.substring(lEdgeName.indexOf(")") + 1);
  22.  
  23.         String lPossibleEdge1 = lVertexName1 + lVertexName2;
  24.         String lPossibleEdge2 = lVertexName2 + lVertexName1;
  25.  
  26.         String lActualEdgeString = lWalkways[lCurrentEdge].getName();
  27.  
  28.         if(lActualEdgeString.equals(lPossibleEdge1) || lActualEdgeString.equals(lPossibleEdge2)){
  29.             lCorrectEdges++;
  30.         }
  31.  
  32.         lCurrentEdge++;
  33.     }
  34.  
  35.     org.junit.Assert.assertEquals("WeightedSmallLabyrinth.txt: dfsPath( (3,3), (1,0) ) returns correct path",
  36.             (Object) (5), (Object) (lCorrectEdges));
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement