示例#1
0
    def testDrawMap(self):
        expected = """ -------------------- 
|                    |
|                    |
|                    |
|                    |
|                    |
|                    |
|                    |
|                    |
|                    |
|                    |
|                    |
|                    |
|                    |
|                    |
|                    |
|                    |
|                    |
|                    |
|                    |
|                    |
 -------------------- """
        snake = Snake()
        actual = snake.draw(None, None)
        self.assertMultiLineEqual(expected, actual, "Expected:\n\n{0}\nActual:\n\n{1}".format(expected, actual))
示例#2
0
    def testDrawSnakeHorizontal(self):
        expected = """ -------------------- 
|                    |
|                    |
|                    |
|                    |
|                    |
|                    |
|                    |
|                    |
|                    |
|     @@@@@          |
|                    |
|                    |
|                    |
|                    |
|                    |
|                    |
|                    |
|                    |
|                    |
|                    |
 -------------------- """
        snake = Snake()
        snakePositions = [Coordinates(10,10), Coordinates(9,10), Coordinates(8,10), Coordinates(7,10), Coordinates(6,10)]
        actual = snake.draw(snakePositions, None)
        self.assertMultiLineEqual(expected, actual, "Expected:\n\n{0}\nActual:\n\n{1}".format(expected, actual))
示例#3
0
    def testDrawOtherFood(self):
        expected = """ -------------------- 
|    *               |
|                    |
|                    |
|                    |
|                    |
|                    |
|                    |
|                    |
|                    |
|     @@@@@         *|
|                    |
|                    |
|                    |
|                    |
|                    |
|                    |
|                    |
| *              *   |
|                    |
|                    |
 -------------------- """
        snake = Snake()
        snakePositions = [Coordinates(10,10), Coordinates(9,10), Coordinates(8,10), Coordinates(7,10), Coordinates(6,10)]
        foodPositions = [Coordinates(5,1), Coordinates(2,18), Coordinates(17,18), Coordinates(20,10)]
        actual = snake.draw(snakePositions, foodPositions)
        self.assertMultiLineEqual(expected, actual, "Expected:\n\n{0}\nActual:\n\n{1}".format(expected, actual))