import java.util.ArrayList; import java.util.Arrays; import junit.framework.TestCase; public class MazeTest extends TestCase { /* * Test file to test code in Maze * * Part of this assignment is for you to think deeply about what test cases * should be included. The test cases we provided are for testing LARGE * Mazes and will test a number of things, but for debugging you should * write small test cases, which each test a single thing. * * Please remember to comment your test cases. */ // comment omitted to not identify the important things to test (that's your // job on this assignment) public void testMaze0() { Maze m0 = new Maze(maze0height, maze0width, maze0str); ArrayList solutionPath = m0.getPath(); System.out.println("***** Maze 0 *****"); System.out.println(solutionPath); String solutionStr = "[(r=2,c=1), (r=3,c=1), (r=3,c=2), (r=3,c=3), (r=2,c=3), (r=2,c=4), (r=2,c=5), (r=2,c=6), (r=2,c=7), (r=3,c=7), (r=4,c=7), (r=4,c=6)]"; assertEquals(solutionPath.toString(), solutionStr); } // comment omitted to not identify the important things to test (that's your // job on this assignment) public void testMaze1() { Maze m1 = new Maze(maze1height, maze1width, maze1str); ArrayList solutionPath = m1.getPath(); System.out.println("***** Maze 1 *****"); System.out.println(solutionPath); String solutionStr = "[(r=7,c=7), (r=6,c=7), (r=5,c=7), (r=4,c=7), (r=3,c=7), (r=2,c=7), (r=2,c=6), (r=2,c=5), (r=2,c=4), (r=2,c=3), (r=2,c=2)]"; assertEquals(solutionPath.toString(), solutionStr); } // comment omitted to not identify the important things to test (that's your // job on this assignment) public void testMaze2() { Maze m2 = new Maze(maze2height, maze2width, maze2str); ArrayList solutionPath = m2.getPath(); System.out.println("***** Maze 2 *****"); System.out.println(solutionPath); String solutionStr = "[(r=2,c=1), (r=3,c=1), (r=4,c=1), (r=5,c=1), (r=6,c=1), (r=7,c=1), (r=8,c=1), (r=9,c=1), (r=10,c=1), (r=11,c=1), (r=12,c=1), (r=13,c=1), (r=14,c=1), (r=15,c=1), (r=16,c=1), (r=17,c=1), (r=18,c=1), (r=19,c=1), (r=20,c=1), (r=21,c=1), (r=22,c=1), (r=23,c=1), (r=24,c=1), (r=25,c=1), (r=26,c=1), (r=27,c=1), (r=28,c=1), (r=29,c=1), (r=30,c=1), (r=30,c=2), (r=30,c=3), (r=30,c=4), (r=30,c=5), (r=30,c=6), (r=30,c=7), (r=30,c=8), (r=30,c=9), (r=30,c=10), (r=30,c=11), (r=30,c=12), (r=30,c=13), (r=30,c=14), (r=30,c=15), (r=30,c=16), (r=30,c=17), (r=30,c=18), (r=30,c=19), (r=30,c=20), (r=30,c=21), (r=30,c=22), (r=30,c=23), (r=30,c=24), (r=30,c=25), (r=30,c=26), (r=30,c=27), (r=30,c=28), (r=30,c=29), (r=30,c=30), (r=30,c=31), (r=30,c=32), (r=30,c=33), (r=30,c=34), (r=30,c=35), (r=30,c=36)]"; assertEquals(solutionPath.toString(), solutionStr); } // comment omitted to not identify the important things to test (that's your // job on this assignment) public void testMaze3() { Maze m3 = new Maze(maze3height, maze3width, maze3str); ArrayList solutionPath = m3.getPath(); System.out.println("***** Maze 3 *****"); System.out.println(solutionPath); String solutionStr = "[(r=8,c=1), (r=7,c=1), (r=7,c=2), (r=7,c=3), (r=7,c=4), (r=7,c=5), (r=7,c=6), (r=7,c=7), (r=8,c=7), (r=9,c=7), (r=9,c=8), (r=9,c=9), (r=9,c=10), (r=9,c=11), (r=9,c=12), (r=9,c=13), (r=10,c=13), (r=11,c=13), (r=12,c=13), (r=13,c=13), (r=13,c=14), (r=13,c=15), (r=13,c=16), (r=13,c=17), (r=13,c=18), (r=13,c=19), (r=13,c=20), (r=13,c=21), (r=13,c=22), (r=13,c=23), (r=13,c=24), (r=13,c=25), (r=13,c=26), (r=13,c=27), (r=13,c=28), (r=13,c=29), (r=13,c=30), (r=13,c=31), (r=14,c=31), (r=15,c=31), (r=15,c=32), (r=15,c=33), (r=15,c=34), (r=15,c=35), (r=15,c=36), (r=15,c=37), (r=16,c=37), (r=17,c=37), (r=18,c=37), (r=19,c=37), (r=20,c=37), (r=21,c=37), (r=21,c=38), (r=21,c=39), (r=21,c=40), (r=22,c=40), (r=23,c=40), (r=24,c=40), (r=25,c=40), (r=26,c=40), (r=27,c=40), (r=27,c=41), (r=27,c=42), (r=27,c=43), (r=27,c=44), (r=27,c=45), (r=27,c=46), (r=28,c=46), (r=29,c=46), (r=30,c=46), (r=31,c=46), (r=32,c=46), (r=33,c=46), (r=33,c=47), (r=33,c=48), (r=33,c=49), (r=34,c=49), (r=35,c=49), (r=36,c=49), (r=37,c=49), (r=38,c=49), (r=39,c=49), (r=39,c=48), (r=39,c=47), (r=40,c=47), (r=41,c=47), (r=41,c=46), (r=41,c=45), (r=41,c=44), (r=41,c=43), (r=41,c=42), (r=41,c=41), (r=41,c=40), (r=41,c=39), (r=41,c=38), (r=41,c=37), (r=41,c=36), (r=41,c=35), (r=41,c=34), (r=41,c=33), (r=41,c=32), (r=42,c=32), (r=43,c=32), (r=43,c=31), (r=43,c=30), (r=43,c=29), (r=44,c=29), (r=45,c=29), (r=46,c=29), (r=47,c=29), (r=48,c=29), (r=49,c=29), (r=49,c=28), (r=49,c=27), (r=49,c=26), (r=49,c=25), (r=49,c=24), (r=49,c=23), (r=49,c=22), (r=49,c=21), (r=49,c=20), (r=48,c=20), (r=47,c=20), (r=47,c=19), (r=47,c=18), (r=47,c=17), (r=48,c=17), (r=49,c=17), (r=49,c=16), (r=49,c=15), (r=49,c=14), (r=49,c=13), (r=49,c=12), (r=49,c=11), (r=48,c=11), (r=47,c=11), (r=47,c=10), (r=47,c=9), (r=47,c=8), (r=48,c=8), (r=49,c=8), (r=49,c=7), (r=49,c=6), (r=49,c=5), (r=49,c=4)]"; assertEquals(solutionPath.toString(), solutionStr); } // comment omitted to not identify the important things to test (that's your // job on this assignment) public void testMaze4() { Maze m4 = new Maze(maze4height, maze4width, maze4str); ArrayList solutionPath = m4.getPath(); System.out.println("***** Maze 4 *****"); System.out.println(solutionPath); assertTrue(solutionPath == null); } // this test will only succeed if you implement the extra credit. public void testMaze5() { Maze m5 = new Maze(maze5height, maze5width, maze5str); ArrayList solutionPath = m5.getPath(); System.out.println("***** Maze 5 (for extra credit) *****"); System.out.println(solutionPath); String solutionStr = "[(r=1,c=0), (r=1,c=9), (r=1,c=8), (r=0,c=8), (r=5,c=8), (r=4,c=8), (r=4,c=7), (r=4,c=6)]"; assertEquals(solutionPath.toString(), solutionStr); } /************************************************************** * Your own test-mazes HERE! :) **************************************************************/ // TODO Add (small and super-small) test mazes here! /************************************************************** * Provided mazes below! Do not reformat :) **************************************************************/ // Maze 0: // ********** // *S* * // * * * // * ** * // * *D * // ********** private int maze0height = 6; private int maze0width = 10; private String maze0str = "***********S* ** * ** ** ** *D ***********"; // Maze 1: // ********** // * * // * D * // * * // * * // * * // * * // * * // * S * // ********** private int maze1height = 10; private int maze1width = 10; private String maze1str = "*********** ** D ** ** ** ** ** ** S ***********"; // Maze 2: // ************************************************** // *S * // * * // * * // * * // * * // * * // * * // * * // * * // * * // * * // * * // * * // * * // * * // * * // * * // * * // * * // * * // * * // * * // * * // * * // * * // * * // * * // * * // * * // * D * // * * // * * // * * // ************************************************** private int maze2height = 35; private int maze2width = 50; private String maze2str = "***************************************************S ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** D ** ** ** ***************************************************"; // Maze 3: // **************************************************************************** // * * * * * * * * * * * * * * * * // **** * * **** **** ********** * **** * * * * ******* * * **** // * * * * * * * * * * * * * * // **** **** **** ******* ********** * * **** * * **** * * * * * // * * * * * * * * * * * * * * * // **** ********** * **** * ******* **** ******* * * **** * ******* // * * * * * * * * * * * // * **** **** **** **** **** **** **** ******* **** * * ********** // *S * * * * * * * * * * // **** ******* ******* **** ******* ******* * ************* * **** * // * * * * * * * * * * * * // * * ******* ******* ******* **** ******* ********** * ******* **** // * * * * * * * * * * * // * **** * **** **** * * * **** * * ********** * * ******* **** // * * * * * * * * * * * * * * // ************* **************** **** * **** **** * **** **** * **** // * * * * * * * * * * * * * // * **** * **** **** ************* * * ******* **** ******* * **** // * * * * * * * * * * * * * * * * // * ************* **** * * * * * **** **** * **** * **** * * * // * * * * * * * * * // **************** **** **** ******* * ********** **** ************* * // * * * * * * * * * * * * * * * * * * // * * **** * **************** ******* * * * **** **** **** **** * // * * * * * * * * * * * // **** **** * * * * * * **** * * **** * * * * **** * * * * // * * * * * * * * * * * * * * // * ********** ******* ********** ********** * **** * * * **** * * // * * * * * * * * * * * * * // **** ******* * * * ******* * * **** * **** * **** **** **** * // * * * * * * * * * * * * * * * // * * **** ******* **** **** **** ******* ******* ********** ******* // * * * * * * * * * * * // **** * * ************* ********** * ******* **** * **** * **** * // * * * * * * * * * * * * * * // **** * * * * * ********** ******* * * * ******* ******* * **** // * * * * * * * * * * * * * * * * // * * ******* * ********** * ******* * **** ******* * ******* * * // * * * * * * * * * * * * * * // ********************** * ******* ********** **** **** **** ******* * // * * * * * * * * // ************* * * **** * * * * ******* * **** **** ********** * // * * * * * * * * * * * * * * // * **** **** **** * **** **** * **** **** **** * * * * * * * // * * * * * * * * * * * * * * * * * * // * ********************** * * * **** * **** ******* **** **** **** // * * * * * * * * * * * * * * * // * **** * * * * ******* ******* * * **** * **** * * * **** * // * *D * * * * * * * * * * * // **************************************************************************** private int maze3height = 51; private int maze3width = 76; private String maze3str = "***************************************************************************** * * * * * * * * * * * * * * ***** * * **** **** ********** * **** * * * * ******* * * ***** * * * * * * * * * * * * ***** **** **** ******* ********** * * **** * * **** * * * * ** * * * * * * * * * * * * * ***** ********** * **** * ******* **** ******* * * **** * ******** * * * * * * * * * ** **** **** **** **** **** **** **** ******* **** * * ***********S * * * * * * * * * ***** ******* ******* **** ******* ******* * ************* * **** ** * * * * * * * * * * ** * ******* ******* ******* **** ******* ********** * ******* ***** * * * * * * * * * ** **** * **** **** * * * **** * * ********** * * ******* ***** * * * * * * * * * * * * ************** **************** **** * **** **** * **** **** * ***** * * * * * * * * * * * ** **** * **** **** ************* * * ******* **** ******* * ***** * * * * * * * * * * * * * * ** ************* **** * * * * * **** **** * **** * **** * * ** * * * * * * * ***************** **** **** ******* * ********** **** ************* ** * * * * * * * * * * * * * * * * ** * **** * **************** ******* * * * **** **** **** **** ** * * * * * * * * * ***** **** * * * * * * **** * * **** * * * * **** * * * ** * * * * * * * * * * * * ** ********** ******* ********** ********** * **** * * * **** * ** * * * * * * * * * * * ***** ******* * * * ******* * * **** * **** * **** **** **** ** * * * * * * * * * * * * * ** * **** ******* **** **** **** ******* ******* ********** ******** * * * * * * * * * ***** * * ************* ********** * ******* **** * **** * **** ** * * * * * * * * * * * * ***** * * * * * ********** ******* * * * ******* ******* * ***** * * * * * * * * * * * * * * ** * ******* * ********** * ******* * **** ******* * ******* * ** * * * * * * * * * * * * *********************** * ******* ********** **** **** **** ******* ** * * * * * * ************** * * **** * * * * ******* * **** **** ********** ** * * * * * * * * * * * * ** **** **** **** * **** **** * **** **** **** * * * * * * ** * * * * * * * * * * * * * * * * ** ********************** * * * **** * **** ******* **** **** ***** * * * * * * * * * * * * * ** **** * * * * ******* ******* * * **** * **** * * * **** ** *D * * * * * * * * * * *****************************************************************************"; // Maze 4: // ********** // *S* * // * **** * // * *** * // * *D * // ********** private int maze4height = 6; private int maze4width = 10; private String maze4str = "***********S* ** **** ** *** ** *D ***********"; // Maze 5: // ******** * // S* // * * * // * ** * // * *D * // ******** * private int maze5height = 6; private int maze5width = 10; private String maze5str = "******** * S* * * ** ** ** *D ********* *"; }