예제 #1
0
    def test_points_adding(self):
        newgame = Game(1, 2)
        newgame.setServe(newgame.player1)

        self.add_score(newgame, newgame.player1, 5)
        self.assertEqual(newgame.getScore(newgame.player1), 5)

        self.add_score(newgame, newgame.player2, 5)
        self.assertEqual(newgame.getScore(newgame.player2), 5)
예제 #2
0
    def test_serving_subtracting(self):
        newgame = Game(1, 2)
        newgame.setServe(newgame.player1)
        self.add_score(newgame, newgame.player1, 5)  # (5)-0
        self.add_score(newgame, newgame.player2, 5)  # 5-(5)

        self.subtract_score(newgame, newgame.player1, 3)  # 2-(5)
        self.assertEqual(newgame.getServe(), 2)

        self.subtract_score(newgame, newgame.player2, 3)  # (2)-2
        self.assertEqual(newgame.getServe(), 1)
예제 #3
0
    def test_serving_adding(self):
        newgame = Game(1, 2)
        newgame.setServe(newgame.player1)

        self.add_score(newgame, newgame.player1, 5)
        # Player1 should be serving
        self.assertEqual(newgame.getServe(), 1)

        self.add_score(newgame, newgame.player2, 5)
        # Player2 should be serving
        self.assertEqual(newgame.getServe(), 2)
예제 #4
0
    def test_tiebreak_win(self):
        game1 = Game(1, 2)
        game1.setServe(game1.player1)
        self.add_score(game1, game1.player1, 10)
        self.add_score(game1, game1.player2, 11)
        self.add_score(game1, game1.player1, 1)
        self.assertFalse(game1.getWinner())

        self.add_score(game1, game1.player2, 2)
        self.assertTrue(game1.getWinner())
        self.assertEqual(game1.getWinner(), game1.player2)
예제 #5
0
    def test_standard_win(self):
        game1 = Game(1, 2)
        game1.setServe(game1.player1)
        self.assertFalse(game1.getWinner())
        self.add_score(game1, game1.player1, 11)
        self.assertTrue(game1.getWinner())
        self.assertEqual(game1.getWinner(), game1.player1)

        game2 = Game(1, 2)
        game2.setServe(game2.player2)
        self.assertFalse(game2.getWinner())
        self.add_score(game2, game2.player2, 11)
        self.assertTrue(game2.getWinner())
        self.assertEqual(game2.getWinner(), game2.player2)
예제 #6
0
    def test_tiebreak_serving(self):
        newgame = Game(1, 2)
        newgame.setServe(newgame.player1)
        self.add_score(newgame, newgame.player1, 10)  # 10-(0)
        self.add_score(newgame, newgame.player1, 10)  # (10)-10
        self.assertEqual(newgame.getServe(), 1)

        self.add_score(newgame, newgame.player1, 1)
        self.assertEqual(newgame.getServe(), 2)
        self.add_score(newgame, newgame.player1, 1)
        self.assertEqual(newgame.getServe(), 1)

        self.add_score(newgame, newgame.player1, 1)
        self.assertEqual(newgame.getServe(), 2)
        self.add_score(newgame, newgame.player1, 1)
        self.assertEqual(newgame.getServe(), 1)
예제 #7
0
 def test_serve_setting(self):
     newgame = Game(1, 2)
     newgame.setServe(newgame.player1)
     self.assertEqual(newgame.getServe(), 1)
     self.assertNotEqual(newgame.getServe(), 2)