def test_vector2d_init(): a = pyjet.Vector2D() assert a.x == 0.0 assert a.y == 0.0 b = pyjet.Vector2D(1, 2) assert b.x == 1.0 assert b.y == 2.0 c = pyjet.Vector2D(y=2, x=1) assert c.x == 1.0 assert c.y == 2.0
def testInit(self): a = pyjet.Vector2D() self.assertEqual(a.x, 0.0) self.assertEqual(a.y, 0.0) b = pyjet.Vector2D(1, 2) self.assertEqual(b.x, 1.0) self.assertEqual(b.y, 2.0) c = pyjet.Vector2D(y=2, x=1) self.assertEqual(c.x, 1.0) self.assertEqual(c.y, 2.0)
def testInit(self): a = pyjet.BoundingBox2D() self.assertGreater(a.lowerCorner.x, a.upperCorner.x) self.assertGreater(a.lowerCorner.y, a.upperCorner.y) b = pyjet.BoundingBox2D((-1, -2), (4, 2)) self.assertEqual(b.lowerCorner.x, -1.0) self.assertEqual(b.lowerCorner.y, -2.0) self.assertEqual(b.upperCorner.x, 4.0) self.assertEqual(b.upperCorner.y, 2.0) l, u = pyjet.Vector2D(-1, -2), pyjet.Vector2D(4, 2) c = pyjet.BoundingBox2D(l, u) self.assertEqual(c.lowerCorner.x, -1.0) self.assertEqual(c.lowerCorner.y, -2.0) self.assertEqual(c.upperCorner.x, 4.0) self.assertEqual(c.upperCorner.y, 2.0)
def test_vector2d_calc(): a = pyjet.Vector2D(1, 2) b = pyjet.Vector2D(4, 6) c = a + b assert c.x == 5.0 assert c.y == 8.0 c = a - b assert c.x == -3.0 assert c.y == -4.0 c = a * b assert c.x == 4.0 assert c.y == 12.0 c = a / b assert c.x == approx(1.0 / 4.0) assert c.y == approx(1.0 / 3.0)
def testCalc(self): a = pyjet.Vector2D(1, 2) b = pyjet.Vector2D(4, 6) c = a + b self.assertEqual(c.x, 5.0) self.assertEqual(c.y, 8.0) c = a - b self.assertEqual(c.x, -3.0) self.assertEqual(c.y, -4.0) c = a * b self.assertEqual(c.x, 4.0) self.assertEqual(c.y, 12.0) c = a / b self.assertAlmostEqual(c.x, 1.0 / 4.0) self.assertAlmostEqual(c.y, 1.0 / 3.0)
def test_bounding_box2d_init(): a = pyjet.BoundingBox2D() assert a.lowerCorner.x > a.upperCorner.x assert a.lowerCorner.y > a.upperCorner.y b = pyjet.BoundingBox2D((-1, -2), (4, 2)) b.lowerCorner.x == -1.0 b.lowerCorner.y == -2.0 b.upperCorner.x == 4.0 b.upperCorner.y == 2.0 l, c = pyjet.Vector2D(-1, -2), pyjet.Vector2D(4, 2) c = pyjet.BoundingBox2D(l, c) c.lowerCorner.x == -1.0 c.lowerCorner.y == -2.0 c.upperCorner.x == 4.0 c.upperCorner.y == 2.0
def test_vector2d_setters(): a = pyjet.Vector2D(1, 2) a[0] = 4 a[1] = 5 assert a[0] == 4 assert a[1] == 5
def test_vector2d_getters(): a = pyjet.Vector2D(1, 2) assert a[0] == 1 assert a[1] == 2
def testSetters(self): a = pyjet.Vector2D(1, 2) a[0] = 4 a[1] = 5 self.assertEqual(a[0], 4) self.assertEqual(a[1], 5)
def testGetters(self): a = pyjet.Vector2D(1, 2) self.assertEqual(a[0], 1) self.assertEqual(a[1], 2)