def test_cwipc_from_points_empty(self): """Can we create a cwipc object from a empty list of values""" points = cwipc.cwipc_point_array(values=[]) pc = cwipc.cwipc_from_points(points, 0) newpoints = pc.get_points() self.assertEqual(len(points), 0) self.assertEqual(len(newpoints), 0) pc.free()
def test_pointarray(self): """Can an empty cwipc_point array be created and the values read back?""" p = cwipc.cwipc_point_array(count=10) self.assertEqual(p[0].x, 0) self.assertEqual(p[0].y, 0) self.assertEqual(p[0].z, 0) self.assertEqual(p[0].r, 0) self.assertEqual(p[0].g, 0) self.assertEqual(p[0].b, 0) self.assertEqual(p[9].x, 0) self.assertEqual(p[9].y, 0) self.assertEqual(p[9].z, 0) self.assertEqual(p[9].r, 0) self.assertEqual(p[9].g, 0) self.assertEqual(p[9].b, 0) with self.assertRaises(IndexError): p[10].x
def test_cwipc_from_points(self): """Can we create a cwipc object from a list of values""" points = cwipc.cwipc_point_array(values=[(1, 2, 3, 0x10, 0x20, 0x30, 1), (4, 5, 6, 0x40, 0x50, 0x60, 2)]) pc = cwipc.cwipc_from_points(points, 0) newpoints = pc.get_points() self.assertEqual(len(points), len(newpoints)) for i in range(len(points)): op = points[i] np = newpoints[i] self.assertEqual(op.x, np.x) self.assertEqual(op.y, np.y) self.assertEqual(op.z, np.z) self.assertEqual(op.r, np.r) self.assertEqual(op.g, np.g) self.assertEqual(op.b, np.b) self.assertEqual(op.tile, np.tile) pc.free()
def test_pointarray_filled(self): """Can a cwipc_point array be created with values and the values read back?""" p = cwipc.cwipc_point_array(values=[(1, 2, 3, 0x10, 0x20, 0x30, 0), (4, 5, 6, 0x40, 0x50, 0x60, 0)]) self.assertEqual(len(p), 2) self.assertEqual(p[0].x, 1) self.assertEqual(p[0].y, 2) self.assertEqual(p[0].z, 3) self.assertEqual(p[0].r, 0x10) self.assertEqual(p[0].g, 0x20) self.assertEqual(p[0].b, 0x30) self.assertEqual(p[1].x, 4) self.assertEqual(p[1].y, 5) self.assertEqual(p[1].z, 6) self.assertEqual(p[1].r, 0x40) self.assertEqual(p[1].g, 0x50) self.assertEqual(p[1].b, 0x60) with self.assertRaises(IndexError): p[2].x
def _build_pointcloud(self): points = cwipc.cwipc_point_array( values=[(1, 2, 3, 0x10, 0x20, 0x30, 1), (4, 5, 6, 0x40, 0x50, 0x60, 2)]) return cwipc.cwipc_from_points(points, 0)