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)
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)
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)
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)
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)
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)
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)
def test_nonnull_ctor(self): bb = objects.BoundingBox(0, 0, 10, 10) self.assertFalse(bb.isnull())
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)
def test_null_ctor(self): bb = objects.BoundingBox() self.assertTrue(bb.isnull())
def test_center(self): bb = objects.BoundingBox(0, 0, 30, 40) c = bb.center() self.assertEqual(c[0], 15) self.assertEqual(c[1], 20)