Example #1
0
 /** Test method to check if accessor for gCost is set correctly for both constructors */
 @Test
 public void testGetGCost() {
   PathNode nodeTest = new PathNode(coords1, node2, coords3, 10);
   assertEquals(10, nodeTest.getGCost());
   PathNode nodeTest2 = new PathNode(coords1, coords2);
   assertEquals(0, nodeTest2.getGCost());
 }
Example #2
0
 /** Test method to check for the manhattan distance between two coordinates. */
 @Test
 public void testManhattanDistance() {
   assertEquals(
       "Return the manhattan distance, should return 3",
       3,
       PathNode.manhattanDistance(coords1, coords2));
 }
Example #3
0
 /** Accessor method test for parent node of a PathNode */
 @Test
 public void testGetParent() {
   PathNode nodeTest = new PathNode(coords1, node2, coords3, 2);
   assertEquals("Check parent node is set correctly", node2, nodeTest.getParent());
 }
Example #4
0
 /** Check accessor method for position: */
 @Test
 public void testGetPosition() {
   assertEquals("Check position accessor method works:", coords1, node1.getPosition());
 }
Example #5
0
 /** Method to test getFCost accessor method, which returns the sum of gCost & hCost. */
 @Test
 public void testGetFCost() {
   PathNode nodeTest = new PathNode(coords1, node2, coords3, 10);
   int fCost = PathNode.manhattanDistance(coords1, coords3) + 10;
   assertEquals("gCost + hCost = fCost", fCost, nodeTest.getFCost());
 }
Example #6
0
 /** Test method for checking if the accessor for hCost is set correctly: */
 @Test
 public void testGetHCost() {
   assertEquals("Check H cost returns and is correct", 3, node1.getHCost());
 }