Пример #1
0
 def test_nonnull_expand_outside(self):
     a = objects.BoundingBox(1, 2, 3, 4)
     b = objects.BoundingBox(0, 0, 4, 5)
     a.expand(b)
     self.assertEqual(a.x1, 0)
     self.assertEqual(a.y1, 0)
     self.assertEqual(a.x2, 4)
     self.assertEqual(a.y2, 5)
Пример #2
0
 def test_null_expand_nonnull(self):
     a = objects.BoundingBox()
     b = objects.BoundingBox(1, 2, 3, 4)
     a.expand(b)
     self.assertEqual(a.x1, 1)
     self.assertEqual(a.y1, 2)
     self.assertEqual(a.x2, 3)
     self.assertEqual(a.y2, 4)
Пример #3
0
 def test_null_expand_null(self):
     a = objects.BoundingBox()
     b = objects.BoundingBox()
     a.expand(b)
     self.assertEqual(a.x1, None)
     self.assertEqual(a.y1, None)
     self.assertEqual(a.x2, None)
     self.assertEqual(a.y2, None)
Пример #4
0
 def test_nonnull_include_outside(self):
     bb = objects.BoundingBox(0, 0, 30, 30)
     bb.include(50, 40)
     self.assertEqual(bb.x1, 0)
     self.assertEqual(bb.y1, 0)
     self.assertEqual(bb.x2, 50)
     self.assertEqual(bb.y2, 40)
Пример #5
0
 def test_nonnull_include_inside(self):
     bb = objects.BoundingBox(0, 0, 30, 30)
     bb.include(10, 20)
     self.assertEqual(bb.x1, 0)
     self.assertEqual(bb.y1, 0)
     self.assertEqual(bb.x2, 30)
     self.assertEqual(bb.y2, 30)
Пример #6
0
 def test_nonnull_include_null(self):
     bb = objects.BoundingBox(0, 0, 30, 30)
     bb.include(None, None)
     self.assertEqual(bb.x1, 0)
     self.assertEqual(bb.y1, 0)
     self.assertEqual(bb.x2, 30)
     self.assertEqual(bb.y2, 30)
Пример #7
0
 def test_null_include(self):
     bb = objects.BoundingBox()
     bb.include(10, 20)
     self.assertEqual(bb.x1, 10)
     self.assertEqual(bb.y1, 20)
     self.assertEqual(bb.x2, 10)
     self.assertEqual(bb.y2, 20)
Пример #8
0
 def test_nonnull_ctor(self):
     bb = objects.BoundingBox(0, 0, 10, 10)
     self.assertFalse(bb.isnull())
Пример #9
0
 def test_repr(self):
     x = repr(objects.BoundingBox(11, 22, 30, 40))
     self.assertIn("11", x)
     self.assertIn("22", x)
     self.assertIn("30", x)
     self.assertIn("40", x)
Пример #10
0
 def test_null_ctor(self):
     bb = objects.BoundingBox()
     self.assertTrue(bb.isnull())
Пример #11
0
 def test_center(self):
     bb = objects.BoundingBox(0, 0, 30, 40)
     c = bb.center()
     self.assertEqual(c[0], 15)
     self.assertEqual(c[1], 20)