Added more tests.

Added a very large map for tests.
Added testing for DFS limiter.
This commit is contained in:
Harrison Deng 2020-04-22 18:41:00 -05:00
parent 44c6880e07
commit c3998150f9
2 changed files with 73 additions and 17 deletions

View File

@ -60,12 +60,14 @@ public class DepthFirstSearchTest {
private byte[][] mapF;
private byte[][] mapG;
private byte[][] mapH;
@BeforeAll
public void setUp() throws IOException {
dfs = new DepthFirstSearch();
mapF = readMap("DFSTestMapLargeA.txt");
mapG = readMap("DFSTestMapLargeB.txt");
mapH = readMap("DFSTestMapLargeC.txt");
}
private byte[][] readMap(String filename) throws IOException {
@ -153,11 +155,32 @@ public class DepthFirstSearchTest {
dfs = new DepthFirstSearch(validator);
dfs.setValidatable(validator);
dfs.setStartPosition(0, 0);
assertTrue(dfs.findTarget(validator));
assertEquals(0, dfs.getEndX());
assertEquals(3, dfs.getEndY());
}
@Test
public void testDFSFindEndNodeMapHValid() {
Validator validator = new Validator(mapH);
dfs.setValidatable(validator);
dfs.setStartPosition(3, 0);
assertTrue(dfs.findTarget(validator));
assertEquals(95, dfs.getEndX());
assertEquals(49, dfs.getEndY());
}
@Test
public void testDFSFindEndNodeMapHInvalidLimited() {
Validator validator = new Validator(mapH);
DepthFirstSearch temporary = new DepthFirstSearch(128, validator);
temporary.setStartPosition(3, 0);
assertFalse(temporary.findTarget(validator));
}
@Test
public void testDFSFindEndNodeMapEInvalid() {
Validator validator = new Validator(mapE);

View File

@ -1,17 +1,50 @@
1111111111111111111111111111111111111111111111111110000000000000
1111111111111111111111111111111100000000000000000000000000111111
0000000000000000000000000000111100000000000000000000000111111111
1111111111111111111111111111111111111111111111111111111111111111
1111111111111000000000000000000011111111111100000000000000000000
1111111110000000000000000000000011111111110000000000000000000000
1111111111000000000000000000000011111111110000000000000000000000
1111111111100000000000000000000011111111111100000000000000000000
1111111111111000000000000000000011111111111111000000000000000000
1111111111111111000000000000000011111111111111111100000000000000
1111111111111111111110000000000011111111111111111111111000000000
1111111111111111111111110000000011111111111111111111111110000000
1111111111111111111111111000000011111111111111111111111100000000
1111111111111111111111110000000011111111111111111111111000000000
1111111111111111111111000000000011111111111111111111100000000000
1111111111111111111110000000000011111111111111111110000000000000
1111111111111111111110111120000000000000000000000000000000000000
0011111111110101010101110111101101000001011110010110111010100111101111111010111000100010010110000100
0011111110111001000011011101111001001100000011100110010000011101100111000110100001111110010101001101
0011111010000110100011100110101101011101001101011100010101101011111111000100110011000101110000010111
1011100000110001011101001111000100011001010110010000001111100111000010010101001111011011011000111101
0011110001100010111110110100011110110010101011111010110000001101100111010011111101000001001010001110
0111100010000011111100010110010010111111110001010001111001011110000100110101100011001001001111010010
1111100101001010101001011101001000101100000011011101110011110111110001101011101010000011001111000111
0111111111100001100101000100110001101000111110000111101111110111011001101111011010001100000001111101
1111101101110111101000110010100000000000011101010110010100100100101001101001010001110101000110010110
1011110000110110000001011011010010111011010010101000001101101101111100100000000000011000100111011111
0101111111111111101001101111011111100011111110001111000110101001100110010010001011011111001010110111
0011101101111101101101110000001001000000000001011010101100011011110010011111111110100010011101111111
1111001011110110001100001110101000110111100100010110000010111001010111001101101101010101010111011111
0111100111010010110010111011100010101101010111101001101011011100010010000100010111101100010101111110
1011000101101100110111110010010110100100011100101000111101101010110111010100000100011000101010001110
0101010001000101100111010100000010010011000011111000000000011100010011000110001010000100011110110011
1100111001011111001011001110011111110010101100100100010100010110110000100101100001000001011000101010
1010111101111111100011100011111001010000000111111010100011001100011001001000110100010010011010010010
0111001100100111110010100101111111101100000001101101001011000000101111001101101010110001001010100001
1110010000100011111111110000110110101001000111101101010010111001000111001101100010111010101100111101
0010100010010101111111110010111011001101110001001100111001110100100000101011000011110101000100001110
0000001100101000111111111110110001011110010011001111001000011010010010101001001100101011000100011111
1101101111000101100100111111111111111000000011010000100101111000101011110110110110110010010111111010
1110101010110100111110110111111110001101001001100110110111011101000111001011101010101010010110101000
0100011000100110110101000000111111100100011110010011011011101001001111011101011001011110100000110010
1100100100100000110101101110011111110101111111110111111011001000101010110110110001010001001010011000
0101110110101011100100100100011111111111000101111110111110100101010101110101101000110010011111100101
0111100001010100100101010101101001101110000111000100111111110000101000000111010001000111011011011010
1011010100010010011101001011010110001110111101000110111111110101111101010000001111110110110111010000
1011001011010101000110110001111011010111000001101001111011111111111011110001000100110100101110101110
0011011010110111001110110110010110100101110000010010101100111111110101101111101010110101110110111000
1001100100000101101000110011011010111110100001011100000101101001110001010001001011100010100010110011
0110010101110110110111011010101000011010010000000110001110010101111010100011000011000100011100110000
0111000111100001101110101110110011001100000010101001111111010110111111011101000100101000011110110011
0100110001000001001111011011011101000101111001110101110010111011011110010011101101010100000110001101
1111000110001111010011101100110001101101011111100101010001101001101111011111000010010110011100100101
0011001101110010110001101001100100101101110010110100100110101101100111111001100101011101111010101010
1001001101110111010000011000011100011011110011100011100111010110111101111111101011111100011100110101
1000011000011101010100001010000101000010111010101011010101001110000010001111111111110111111011000000
1011010011111010101001011001110011111110001000000111101110001001110000001111111111100011111001000110
0110110111001100000001100101110111101011000011000111001100110111101000011110001011111111011110011101
0000101101011000100110001111100101101100011111101001110000110111100010010101010101110100000100100000
0011011100101110101000111110110011001101000110000110010010010000101001001111001111111111100011110001
1011000011010010000100000010110000101001000101010000100011100110100111011010011000010111111101100101
1001011000111111111010011010100001100111000111000001011111011110101100011000001110000111111011101101
1110101001110011111110101110001110111100010100010110111001000100010100110011101001111101111110110100
1010000100000100101101111001111101111110111001101000000110111100000110011111000001011011111110111001
1010011010111001010111011101000011010100001001101101110011101100000110100011111011101001111111101101
0011011110111000111101000110000111101000111101001011011100110011010000111011010000011110110111111101
1100010110001111010011101000001011010011000011111010010011011000110101011000001110100000110111120011