def test_BBox2i(self): bb = d.BBox2i(d.ivec2(1, 2)) self.assertEqual(bb.min, d.ivec2(1, 2)) self.assertEqual(bb.max, d.ivec2(1, 2)) bb = d.BBox2i(d.ivec2(1, 2), d.ivec2(3, 4)) self.assertEqual(bb.min, d.ivec2(1, 2)) self.assertEqual(bb.max, d.ivec2(3, 4)) bb = d.BBox2i(1, 2, 3, 4) self.assertEqual(bb.min, d.ivec2(1, 2)) self.assertEqual(bb.max, d.ivec2(3, 5)) self.assertTrue(bb.isValid()) bb.min = d.ivec2(3, 4) bb.max = d.ivec2(1, 2) self.assertEqual(bb, d.BBox2i(d.ivec2(3, 4), d.ivec2(1, 2))) self.assertFalse(bb.isValid()) bb = d.BBox2i(1, 2, 3, 4) self.assertEqual(bb.x(), 1) self.assertEqual(bb.y(), 2) self.assertEqual(bb.w(), 3) self.assertEqual(bb.h(), 4) self.assertEqual(bb.getSize().x, 3) self.assertEqual(bb.getSize().y, 4) self.assertEqual(bb.getCenter().x, 2) self.assertEqual(bb.getCenter().y, 3) self.assertEqual(bb.getArea(), 12) print("Aspect =", bb.getAspect()) bb.zero() self.assertEqual(bb, d.BBox2i(d.ivec2(0, 0), d.ivec2(0, 0))) self.assertTrue(d.BBox2i(1, 2, 3, 4).intersects(d.BBox2i(2, 3, 3, 4))) self.assertFalse(d.BBox2i(1, 2, 3, 4).intersects(d.BBox2i(5, 6, 3, 4)))
def test_util2i(self): a = d.BBox2i(0, 1, 2, 3) #self.assertTrue(a.contains(d.BBox2i(0, 1, 1, 1))) #self.assertFalse(a.contains(d.BBox2i(3, 5, 1, 1))) #self.assertTrue(a.contains(d.ivec2(0, 1))) #self.assertFalse(a.contains(d.ivec2(0, 0))) self.assertTrue(a.intersects(d.BBox2i(0, 1, 3, 4))) b = a.intersect(d.BBox2i(1, 2, 3, 4)) self.assertEqual(b, d.BBox2i(1, 2, 1, 2))
def test_ctor2i(self): b = d.BBox2i(d.ivec2(0, 1)) self.assertEqual(b.min, d.ivec2(0, 1)) self.assertEqual(b.max, d.ivec2(0, 1)) b = d.BBox2i(d.ivec2(0, 1), d.ivec2(2, 3)) self.assertEqual(b.min, d.ivec2(0, 1)) self.assertEqual(b.max, d.ivec2(2, 3)) b = d.BBox2i(0, 1, 2, 3) self.assertEqual(b.min, d.ivec2(0, 1)) self.assertEqual(b.max, d.ivec2(1, 3))
def test_components2i(self): b = d.BBox2i(0, 1, 2, 3) self.assertEqual(b.x(), 0) self.assertEqual(b.y(), 1) self.assertEqual(b.w(), 2) self.assertEqual(b.h(), 3) self.assertTrue(b.isValid()) b.max = d.ivec2(0, 0) self.assertFalse(b.isValid()) b = d.BBox2i(0, 1, 2, 4) self.assertEqual(d.ivec2(2, 4), b.getSize()) self.assertEqual(d.ivec2(1, 3), b.getCenter()) self.assertEqual(8, b.getArea()) self.assertEqual(0.5, b.getAspect()) b.zero() self.assertEqual(d.ivec2(0, 0), b.min) self.assertEqual(d.ivec2(0, 0), b.max)
def test_util2i_comparison(self): a = d.BBox2i(0, 1, 2, 3) b = d.BBox2i(0, 0, 0, 0) self.assertEqual(a, a) self.assertNotEqual(a, b)