def test_winner_oh(self): g = Game() g.place(0, 0, g.OH) self.assertTrue(g.is_valid_board()) g.place(1, 0, g.EX) self.assertTrue(g.is_valid_board()) g.place(0, 1, g.OH) self.assertTrue(g.is_valid_board()) g.place(1, 1, g.EX) self.assertTrue(g.is_valid_board()) g.place(0, 2, g.OH) self.assertTrue(g.is_valid_board()) self.assertEqual(g.get_winning_player(), g.OH)
def test_invalid_four_moves(self): g = Game() g.place(0, 0, g.EX) g.place(1, 0, g.OH) g.place(0, 1, g.EX) g.place(2, 1, g.EX) self.assertFalse(g.is_valid_board())
def test_two_winners(self): g = Game() g.place(0, 0, g.EX) g.place(0, 1, g.EX) g.place(0, 2, g.EX) g.place(1, 0, g.OH) g.place(1, 1, g.OH) g.place(1, 2, g.OH) self.assertFalse(g.is_valid_board())
def test_won_twice_plus(self): g = Game() g.place(0, 1, g.EX) g.place(1, 0, g.EX) g.place(1, 1, g.EX) g.place(1, 2, g.EX) g.place(2, 1, g.EX) g.place(0, 0, g.OH) g.place(0, 2, g.OH) g.place(2, 0, g.OH) g.place(2, 2, g.OH) self.assertFalse(g.is_valid_board())
def test_valid_single_move(self): g = Game() g.place(0, 0, g.EX) self.assertTrue(g.is_valid_board())
def test_initial_board_valid(self): """Ensure the initial blank board is valid.""" g = Game() self.assertTrue(g.is_valid_board())
def test_valid_three_moves(self): g = Game() g.place(0, 0, g.EX) g.place(1, 0, g.OH) g.place(0, 1, g.EX) self.assertTrue(g.is_valid_board())