示例#1
0
    def test_does_ball_hit_wall_9(self):
        """
        Corner case: Does not hit but would do so if the line were longer v3.
        """
        lines = set([Line(1, 5, 1, 4)])
        ball = Ball(1, 0, 1)
        layout = MazeLayout(lines, START_DUMMY, END_DUMMY, SIZE_DUMMY)

        assert (layout.does_ball_hit_wall(ball) == False)
示例#2
0
    def test_does_ball_hit_wall_5(self):
        """
        Base case: 2 walls, one hits.
        """
        lines = set([Line(6, 9, 9, 2), Line(2, 0, 9, 6)])
        ball = Ball(2, 1, 1)
        layout = MazeLayout(lines, START_DUMMY, END_DUMMY, SIZE_DUMMY)

        assert (layout.does_ball_hit_wall(ball) == True)
示例#3
0
    def test_does_ball_hit_wall_6(self):
        """
        Corner case: endpoints of line are far away.
        """
        lines = set([Line(0, 0, 10, 10)])
        ball = Ball(5, 5, 1)
        layout = MazeLayout(lines, START_DUMMY, END_DUMMY, SIZE_DUMMY)

        assert (layout.does_ball_hit_wall(ball) == True)
示例#4
0
    def test_does_ball_hit_wall_3(self):
        """
        Corner case: normal ball just hits a wall.
        """
        lines = set([Line(3, 3, 3, 0)])
        ball = Ball(0, 1.5, 3)
        layout = MazeLayout(lines, START_DUMMY, END_DUMMY, SIZE_DUMMY)

        assert (layout.does_ball_hit_wall(ball) == True)
示例#5
0
    def test_does_ball_hit_wall_4(self):
        """
        Base case: 2 walls, no hit.
        """
        lines = set([Line(6, 9, 9, 2), Line(2, 0, 9, 6)])
        ball = Ball(11, 12, 1)
        layout = MazeLayout(lines, START_DUMMY, END_DUMMY, SIZE_DUMMY)

        assert (layout.does_ball_hit_wall(ball) == False)
示例#6
0
    def test_does_ball_hit_wall_2(self):
        """
        Base case: normal ball does not hit a wall.
        """
        lines = set([Line(0, 3, 3, 0)])
        ball = Ball(0, 0, 1)
        layout = MazeLayout(lines, START_DUMMY, END_DUMMY, SIZE_DUMMY)

        assert (layout.does_ball_hit_wall(ball) == False)
示例#7
0
    def test_does_ball_hit_wall_1(self):
        """
        Base case: normal ball hits normal wall.
        """
        lines = set([Line(0, 3, 3, 0)])
        ball = Ball(0, 0, 2.5)
        layout = MazeLayout(lines, START_DUMMY, END_DUMMY, SIZE_DUMMY)

        assert (layout.does_ball_hit_wall(ball) == True)
示例#8
0
    def test_does_ball_hit_wall_12(self):
        """
        Corner case: Hits, both points of line right of ball center.
        """
        lines = set([Line(100, 200, 100, 0)])
        ball = Ball(99, 100, 3)
        layout = MazeLayout(lines, START_DUMMY, END_DUMMY, SIZE_DUMMY)

        assert (layout.does_ball_hit_wall(ball) == True)
示例#9
0
    def test_does_ball_hit_wall_14(self):
        """
        Corner case: Does not hit but would do so if the line were longer v5:
        One point bigger y and one point smaller y than ball.
        """
        lines = set([Line(0, 99.9, 95, 100.1)])
        ball = Ball(100, 100, 4)
        layout = MazeLayout(lines, START_DUMMY, END_DUMMY, SIZE_DUMMY)

        assert (layout.does_ball_hit_wall(ball) == False)
示例#10
0
    def test_does_ball_hit_wall_13(self):
        """
        Corner case: coordinates line points all smaller than
        ball coordinate values (of respective dims).
        """
        lines = set([Line(3, 0, 0, 3)])
        ball = Ball(3, 3, 5.5)
        layout = MazeLayout(lines, START_DUMMY, END_DUMMY, SIZE_DUMMY)

        assert (layout.does_ball_hit_wall(ball) == True)