Example #1
0
    def test_typical_case(self):
        from construction import RectangularRegion

        region = RectangularRegion(x=20, y=30, width=50, height=40)
        subregion = region.right_subregion(40)

        self.assertEqual(subregion.x, 40)
        self.assertEqual(subregion.width, 30)
        self.assertEqual(subregion.y, 30)
        self.assertEqual(subregion.height, 40)
Example #2
0
    def test_subregion_above_gives_whole_region(self):
        from construction import RectangularRegion

        region = RectangularRegion(x=20, y=30, width=50, height=40)

        subregion = region.subregion_above(y=150)

        self.assertEqual(subregion.x, 20)
        self.assertEqual(subregion.width, 50)
        self.assertEqual(subregion.y, 30)
        self.assertEqual(subregion.height, 40)
Example #3
0
    def test_subregion_below_produces_zero_area_region(self):
        from construction import RectangularRegion

        region = RectangularRegion(x=20, y=30, width=50, height=40)

        subregion = region.subregion_below(y=100)

        self.assertEqual(subregion.x, 20)
        self.assertEqual(subregion.width, 50)
        self.assertEqual(subregion.y, 70)
        self.assertEqual(subregion.height, 0)
Example #4
0
    def test_subregion_below_normal_case(self):
        from construction import RectangularRegion

        region = RectangularRegion(x=20, y=30, width=50, height=40)

        subregion = region.subregion_below(y=40)

        self.assertEqual(subregion.x, 20)
        self.assertEqual(subregion.width, 50)
        self.assertEqual(subregion.y, 40)
        self.assertEqual(subregion.height, 30)
Example #5
0
    def test_subregion_formed_outside_original_area(self):
        from construction import RectangularRegion

        region = RectangularRegion(x=20, y=30, width=50, height=40)
        region.left_subregion(-10).subregion_below(400)