Esempio n. 1
0
    def test_contains_point(self):
        rect = Rectangle(Field(5, 5), Field(10, 10))
        test_cases = {
            Point(0, 0): False,
            Point(2, 4): False,
            Point(7, 14): False,
            Point(15, 18): False,
            Point.map_to_point(rect.bottom_left): False,
            Point.map_to_point(rect.bottom_right): False,
            Point.map_to_point(rect.top_left): False,
            Point.map_to_point(rect.top_right): False,
            Point.map_to_point(rect.middle().top_left): True,
            Point.map_to_point(rect.middle().top_right): True,
            Point.map_to_point(rect.middle().bottom_left): True,
            Point.map_to_point(rect.middle().bottom_right): True,
            Point(6, 8): True,
            Point(8, 9): True
        }

        for point, expected in test_cases.items():
            self.assertEqual(point in rect, expected)
Esempio n. 2
0
 def corner_shell(self):
     start = Point.map_to_point(self.bottom_left)
     end = Point.map_to_point(self.top_right)
     return Rectangle(start, end)