def testDuplicateSpotScatter(self): random.seed(3) expected_board = [[2,-1],[-1,2]] test_board = Board(2,2) test_board.scatter_bombs(2, rand=random.random) observed_board = test_board.board self.assertEqual(expected_board, observed_board)
def testBombReveal(self): random.seed(0xDEADBEEF) expected_value = -1 test_board = Board(5, 5) test_board.scatter_bombs(5, rand=random.random) observed_value = test_board.reveal_location(0, 2) self.assertEqual(expected_value, observed_value)
def testMulitCellRevealCounter(self): random.seed(0xDEADBEEF) expected_value = 19 test_board = Board(5, 5) test_board.scatter_bombs(5, rand=random.random) observed_value = test_board.reveal_location(0, 4) self.assertEqual(expected_value, observed_value)
def testSingleCellReveal(self): random.seed(0xDEADBEEF) expected_board = [[False, True], [False, False]] test_board = Board(2,2) test_board.scatter_bombs(1, rand=random.random) test_board.reveal_location(1,0) observed_board = test_board.trackboard self.assertEqual(expected_board, observed_board)
def testNormalScatter(self): # Fake out the random number generator random.seed(0xDEADBEEF) expected_board = [[-1,1],[1,1]] test_board = Board(2,2) test_board.scatter_bombs(1, rand=random.random) observed_board = test_board.board self.assertEqual(expected_board, observed_board)
def testMultiCellReveal(self): random.seed(6702) expected_board = [[True, True, False], [True, True, False], [False, False, False]] test_board = Board(3,3) test_board.scatter_bombs(4, random.random) test_board.reveal_location(0,0) observed_board = test_board.trackboard self.assertEqual(expected_board, observed_board)
def testBombCellReveal(self): random.seed(0xDEADBEEF) expected_board = " 0 1 2 3 4\n" + \ "0: |_|_|_|_|_|\n" + \ "1: |_|_|_|_|_|\n" + \ "2: |*|_|_|_|_|\n" + \ "3: |_|_|_|_|_|\n" + \ "4: |_|_|_|_|_|" test_board = Board(5,5) test_board.scatter_bombs(5, rand=random.random) test_board.reveal_location(0,2) observed_board = str(test_board) self.assertEqual(expected_board, observed_board)