예제 #1
0
 def test_mine_surrounded_by_spaces(self):
     inp = ["   ",
            " * ",
            "   "]
     out = ["111",
            "1*1",
            "111"]
     self.assertEqual(board(inp), out)
예제 #2
0
 def test_space_surrounded_by_mines(self):
     inp = ["***",
            "* *",
            "***"]
     out = ["***",
            "*8*",
            "***"]
     self.assertEqual(board(inp), out)
예제 #3
0
 def test_no_mines(self):
     inp = ["   ",
            "   ",
            "   "]
     out = ["   ",
            "   ",
            "   "]
     self.assertEqual(board(inp), out)
예제 #4
0
 def test_board_with_only_mines(self):
     inp = ["***",
            "***",
            "***"]
     out = ["***",
            "***",
            "***"]
     self.assertEqual(board(inp), out)
 def test_board3(self):
     inp = ["+-----+",
            "| * * |",
            "+-----+"]
     out = ["+-----+",
            "|1*2*1|",
            "+-----+"]
     self.assertEqual(out, board(inp))
 def test_board5(self):
     inp = ["+-+",
            "|*|",
            "+-+"]
     out = ["+-+",
            "|*|",
            "+-+"]
     self.assertEqual(out, board(inp))
예제 #7
0
 def test_board7(self):
     inp = ["+--+",
            "|**|",
            "|**|",
            "+--+"]
     out = ["+--+",
            "|**|",
            "|**|",
            "+--+"]
     self.assertEqual(board(inp), out)
예제 #8
0
 def test_board9(self):
     inp = ["     ",
            "   * ",
            "     ",
            "     ",
            " *   "]
     out = ["  111",
            "  1*1",
            "  111",
            "111  ",
            "1*1  "]
     self.assertEqual(board(inp), out)
예제 #9
0
 def test_vertical_line_mines_at_edges(self):
     inp = ["*",
            " ",
            " ",
            " ",
            "*"]
     out = ["*",
            "1",
            " ",
            "1",
            "*"]
     self.assertEqual(board(inp), out)
예제 #10
0
 def test_cross(self):
     inp = ["  *  ",
            "  *  ",
            "*****",
            "  *  ",
            "  *  "]
     out = [" 2*2 ",
            "25*52",
            "*****",
            "25*52",
            " 2*2 "]
     self.assertEqual(board(inp), out)
예제 #11
0
 def test_vertical_line(self):
     inp = [" ",
            "*",
            " ",
            "*",
            " "]
     out = ["1",
            "*",
            "2",
            "*",
            "1"]
     self.assertEqual(board(inp), out)
예제 #12
0
 def test_large_board(self):
     inp = [" *  * ",
            "  *   ",
            "    * ",
            "   * *",
            " *  * ",
            "      "]
     out = ["1*22*1",
            "12*322",
            " 123*2",
            "112*4*",
            "1*22*2",
            "111111"]
     self.assertEqual(board(inp), out)
 def test_board9(self):
     inp = ["+-----+",
            "|     |",
            "|   * |",
            "|     |",
            "|     |",
            "| *   |",
            "+-----+"]
     out = ["+-----+",
            "|  111|",
            "|  1*1|",
            "|  111|",
            "|111  |",
            "|1*1  |",
            "+-----+"]
     self.assertEqual(out, board(inp))
 def test_board2(self):
     inp = ["+-----+",
            "| * * |",
            "|     |",
            "|   * |",
            "|  * *|",
            "| * * |",
            "+-----+"]
     out = ["+-----+",
            "|1*2*1|",
            "|11322|",
            "| 12*2|",
            "|12*4*|",
            "|1*3*2|",
            "+-----+"]
     self.assertEqual(out, board(inp))
예제 #15
0
 def test_board4(self):
     inp = ["+-+",
            "|*|",
            "| |",
            "|*|",
            "| |",
            "| |",
            "+-+"]
     out = ["+-+",
            "|*|",
            "|2|",
            "|*|",
            "|1|",
            "| |",
            "+-+"]
     self.assertEqual(board(inp), out)
예제 #16
0
 def test_board1(self):
     inp = ["+------+",
            "| *  * |",
            "|  *   |",
            "|    * |",
            "|   * *|",
            "| *  * |",
            "|      |",
            "+------+"]
     out = ["+------+",
            "|1*22*1|",
            "|12*322|",
            "| 123*2|",
            "|112*4*|",
            "|1*22*2|",
            "|111111|",
            "+------+"]
     self.assertEqual(board(inp), out)
예제 #17
0
 def test_faulty_border(self):
     inp = ["+-----+", "*   * |", "+-- --+"]
     with self.assertRaises(ValueError):
         board(inp)
예제 #18
0
 def test_horizontal_line_mines_at_edges(self):
     inp = ["*   *"]
     out = ["*1 1*"]
     self.assertEqual(board(inp), out)
예제 #19
0
 def test_different_len(self):
     inp = ["+-+", "| |", "|*  |", "|  |", "+-+"]
     with self.assertRaises(ValueError) as context:
         board(inp)
     self.assertEqual(context.exception.message, 'Invalid board')
예제 #20
0
 def test_no_columns(self):
     self.assertEqual(board([""]), [""])
예제 #21
0
 def test_invalid_char(self):
     inp = ["X  * "]
     with self.assertRaisesWithMessage(ValueError):
         board(inp)
예제 #22
0
 def test_board9(self):
     inp = ["     ", "   * ", "     ", "     ", " *   "]
     out = ["  111", "  1*1", "  111", "111  ", "1*1  "]
     self.assertEqual(board(inp), out)
예제 #23
0
 def test_invalid_char(self):
     inp = ["+-----+", "|X  * |", "+-----+"]
     with self.assertRaises(ValueError) as context:
         board(inp)
     self.assertEqual(context.exception.message, 'Invalid board')
예제 #24
0
 def test_horizontal_line(self):
     inp = [" * * "]
     out = ["1*2*1"]
     self.assertEqual(board(inp), out)
예제 #25
0
 def test_horizontal_line_mines_at_edges(self):
     inp = ["*   *"]
     out = ["*1 1*"]
     self.assertEqual(board(inp), out)
예제 #26
0
 def test_board8(self):
     inp = ["+---+", "|***|", "|* *|", "|***|", "+---+"]
     out = ["+---+", "|***|", "|*8*|", "|***|", "+---+"]
     self.assertEqual(out, board(inp))
예제 #27
0
 def test_different_len(self):
     inp = [" ",
            "*  ",
            "  "]
     with self.assertRaisesWithMessage(ValueError):
         board(inp)
예제 #28
0
 def test_invalid_char(self):
     inp = ["X  * "]
     with self.assertRaisesWithMessage(ValueError):
         board(inp)
예제 #29
0
 def test_board5(self):
     inp = ["+-+", "|*|", "+-+"]
     out = ["+-+", "|*|", "+-+"]
     self.assertEqual(out, board(inp))
예제 #30
0
 def test_no_rows(self):
     self.assertEqual(board([]), [])
예제 #31
0
 def test_large_board(self):
     inp = [" *  * ", "  *   ", "    * ", "   * *", " *  * ", "      "]
     out = ["1*22*1", "12*322", " 123*2", "112*4*", "1*22*2", "111111"]
     self.assertEqual(board(inp), out)
예제 #32
0
 def test_no_columns(self):
     self.assertEqual(board([""]), [""])
예제 #33
0
 def test_different_len(self):
     inp = [" ",
            "*  ",
            "  "]
     with self.assertRaisesWithMessage(ValueError):
         board(inp)
예제 #34
0
 def test_board_with_only_mines(self):
     inp = ["***", "***", "***"]
     out = ["***", "***", "***"]
     self.assertEqual(board(inp), out)
예제 #35
0
 def test_no_rows(self):
     self.assertEqual(board([]), [])
예제 #36
0
 def test_space_surrounded_by_mines(self):
     inp = ["***", "* *", "***"]
     out = ["***", "*8*", "***"]
     self.assertEqual(board(inp), out)
예제 #37
0
 def test_no_mines(self):
     inp = ["   ", "   ", "   "]
     out = ["   ", "   ", "   "]
     self.assertEqual(board(inp), out)
예제 #38
0
 def test_invalid_char(self):
     inp = ["+-----+", "|X  * |", "+-----+"]
     with self.assertRaises(ValueError):
         board(inp)
예제 #39
0
 def test_mine_surrounded_by_spaces(self):
     inp = ["   ", " * ", "   "]
     out = ["111", "1*1", "111"]
     self.assertEqual(board(inp), out)
예제 #40
0
 def test_vertical_line_mines_at_edges(self):
     inp = ["*", " ", " ", " ", "*"]
     out = ["*", "1", " ", "1", "*"]
     self.assertEqual(board(inp), out)
예제 #41
0
 def test_horizontal_line(self):
     inp = [" * * "]
     out = ["1*2*1"]
     self.assertEqual(board(inp), out)
예제 #42
0
 def test_board7(self):
     inp = ["+--+", "|**|", "|**|", "+--+"]
     out = ["+--+", "|**|", "|**|", "+--+"]
     self.assertEqual(board(inp), out)
예제 #43
0
 def test_vertical_line(self):
     inp = [" ", "*", " ", "*", " "]
     out = ["1", "*", "2", "*", "1"]
     self.assertEqual(board(inp), out)
예제 #44
0
 def test_different_len(self):
     inp = ["+-+", "| |", "|*  |", "|  |", "+-+"]
     with self.assertRaises(ValueError):
         board(inp)
예제 #45
0
 def test_cross(self):
     inp = ["  *  ", "  *  ", "*****", "  *  ", "  *  "]
     out = [" 2*2 ", "25*52", "*****", "25*52", " 2*2 "]
     self.assertEqual(board(inp), out)
예제 #46
0
 def test_board4(self):
     inp = ["+-+", "|*|", "| |", "|*|", "| |", "| |", "+-+"]
     out = ["+-+", "|*|", "|2|", "|*|", "|1|", "| |", "+-+"]
     self.assertEqual(board(inp), out)