コード例 #1
0
 def test_move(self):
     # normal movement
     pacman = Pacman(0,0,NORTH)
     pacman.move()
     self.assertEqual(pacman.x, 0)
     self.assertEqual(pacman.y, 1)
     # move around
     pacman.move()
     pacman.move()
     pacman.changeDirection(RIGHT)
     pacman.move()
     pacman.move()
     self.assertEqual(pacman.x, 2)
     self.assertEqual(pacman.y, 3)
コード例 #2
0
 def test_changeDirection(self):
     # test change once
     pacman = Pacman(0,0,NORTH)
     pacman.changeDirection(LEFT)
     self.assertEqual(pacman.direction, WEST)
     pacman.changeDirection(RIGHT)
     pacman.changeDirection(RIGHT)
     pacman.changeDirection(RIGHT)
     pacman.changeDirection(RIGHT)
     pacman.changeDirection(RIGHT)
     # test go around a circle
     self.assertEqual(pacman.direction, NORTH)