Ejemplo n.º 1
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)
Ejemplo n.º 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)
Ejemplo n.º 3
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)
Ejemplo n.º 4
0
 def test_serve_setting(self):
     newgame = Game(1, 2)
     newgame.setServe(newgame.player1)
     self.assertEqual(newgame.getServe(), 1)
     self.assertNotEqual(newgame.getServe(), 2)