Example #1
0
	def test_points (self):
		r = Rectangle(Point(0,0), 1, 1)
		p = [
			Point(0,0),
			Point(1,0),
			Point(1,1),
			Point(0,1)
		]

		x = r.points()

		self.assertEqual(len(x), len(p))

		for i in range(len(x)):
			self.assertEqual(x[i],p[i])
Example #2
0
	def test_edges_2 (self):
		r = Rectangle(Point(0,0), 1, 1)
		l = [
			Line(Point(0, 0), Point(1, 0)),
			Line(Point(1, 1), Point(1, 0)),
			Line(Point(0, 1), Point(1, 1)),
			Line(Point(0, 0), Point(0, 1)),
		]

		x = r.edges()

		self.assertEqual(len(x), len(l))

		for i in range(len(x)):
			self.assertEqual(x[i], l[i])
Example #3
0
    def test_filter(self):

        f = RectAreaFilter(150, 950)

        r = [
            Rectangle(Point(0, 0), 10, 10),  #100  -- no
            Rectangle(Point(0, 0), 20, 20),  #400  -- yes
            Rectangle(Point(0, 0), 30, 30),  #900  -- yes
            Rectangle(Point(0, 0), 40, 40),  #1600 -- no
            Rectangle(Point(0, 0), 50, 50),  #2500 -- no
        ]

        s = ProxRectAnalizer.filter(r, [f])

        self.assertIn(Rectangle(Point(0, 0), 20, 20), s)
        self.assertIn(Rectangle(Point(0, 0), 30, 30), s)
Example #4
0
    def test_multiple_filter(self):

        f = RectAreaFilter(300, 500)
        g = RectAreaFilter(800, 950)

        r = [
            Rectangle(Point(0, 0), 10, 10),  #100  -- no
            Rectangle(Point(0, 0), 20, 20),  #400  -- yes (in f)
            Rectangle(Point(0, 0), 30, 30),  #900  -- yes (in g)
            Rectangle(Point(0, 0), 40, 40),  #1600 -- no
            Rectangle(Point(0, 0), 50, 50),  #2500 -- no
        ]

        s = ProxRectAnalizer.filter(r, [f, g])

        self.assertIn(Rectangle(Point(0, 0), 20, 20), s)
        self.assertIn(Rectangle(Point(0, 0), 30, 30), s)
Example #5
0
	def test_diagonal (self):
		r = Rectangle(Point(0,0), 10, 10)
		d = Line(Point(0,0), Point(10,10))
		self.assertEqual(r.diagonal(), d) 
Example #6
0
	def test_center (self):
		r = Rectangle(Point(0,0),10,10)
		p = Point(5,5)
		self.assertEqual(r.center(), p)
Example #7
0
 def test_upper_bound_area_rect(self):
     # check rectangle of area 10x10 = 100
     # should return true
     r = Rectangle(Point(0, 0), 10, 10)  # area = 10 x 10 = 100
     self.assertTrue(self.f.toFilter(r))
Example #8
0
 def test_lower_bound_area_rect(self):
     # check rectangle of area 3x3 = 9
     # should return true
     r = Rectangle(Point(0, 0), 3, 3)  # area = 3 x 3 = 9
     self.assertTrue(self.f.toFilter(r))
Example #9
0
 def test_inside_area_rect(self):
     # check rectangle of area 5x5 > 9, < 100
     # should return true
     r = Rectangle(Point(0, 0), 5, 5)  # area = 5 x 5 = 25
     self.assertTrue(self.f.toFilter(r))
Example #10
0
 def test_upper_area_rect(self):
     # check rectangle of area 11x11 > 100
     # should return false
     r = Rectangle(Point(0, 0), 11, 11)  # area = 11 x 11 = 121
     self.assertFalse(self.f.toFilter(r))
Example #11
0
 def test_lower_area_rect(self):
     # check rectangle of area 1x1 < 9
     # should return false
     r = Rectangle(Point(0, 0), 1, 1)  # area = 1 x 1 = 1
     self.assertFalse(self.f.toFilter(r))