#define BOOST_TEST_DYN_LINK #include #include // These unit tests assume (for now) that there are at least two // coordinate systems with id 0 and 1. using boost::unit_test::label; using RAT::DU::Point3D; struct GlobalFixture { GlobalFixture() {} ~GlobalFixture() {} void setup() { BOOST_TEST_MESSAGE( "GlobalFixture setup() called" ); Point3D::BeginOfRun(); } void teardown() {} }; BOOST_TEST_GLOBAL_FIXTURE( GlobalFixture ); BOOST_AUTO_TEST_SUITE( point3d, *label("du") ) BOOST_AUTO_TEST_CASE( static_init_test ) { //Point3D::BeginOfRun(); BOOST_TEST( Point3D::GetSystemCount() > 0 ); size_t n = Point3D::GetSystemCount(); for (size_t i = 0; i < n; ++i) { BOOST_TEST_INFO_SCOPE("System id = " << i); BOOST_TEST( ((Point3D::HasZOffset(i) && Point3D::GetZOffset(i) != 0.0) || (!Point3D::HasZOffset(i) && Point3D::GetZOffset(i) == 0.0)) ); std::string s = Point3D::GetSystemName(i); BOOST_TEST( Point3D::GetSystemId(s) == i ); } } BOOST_AUTO_TEST_CASE( constructors_test ) { //Point3D::BeginOfRun(); Point3D p; BOOST_TEST( p.GetCoordinateSystem() == 0 ); BOOST_TEST( p.X() == 0.0 ); BOOST_TEST( p.Y() == 0.0 ); BOOST_TEST( p.Z() == 0.0 ); Point3D q(0, 3.0, 4.5, 5.25); BOOST_TEST( q.GetCoordinateSystem() == 0 ); BOOST_TEST( q.X() == 3.0 ); BOOST_TEST( q.Y() == 4.5 ); BOOST_TEST( q.Z() == 5.25 ); Point3D q2(q); // copy constructor BOOST_TEST( q2.GetCoordinateSystem() == 0 ); BOOST_TEST( q2.X() == 3.0 ); BOOST_TEST( q2.Y() == 4.5 ); BOOST_TEST( q2.Z() == 5.25 ); Point3D q3(0, q); // copy constructor with coordinate system change BOOST_TEST( q3.GetCoordinateSystem() == 0 ); BOOST_TEST( q3.X() == 3.0 ); BOOST_TEST( q3.Y() == 4.5 ); BOOST_TEST( q3.Z() == 5.25 ); } BOOST_AUTO_TEST_CASE( system_change_test ) { //Point3D::BeginOfRun(); Point3D p(0, 3.0, 4.5, 5.25); Point3D q(1, p); BOOST_TEST( q.GetCoordinateSystem() == 1 ); BOOST_TEST( q.X() == 3.0 ); BOOST_TEST( q.Y() == 4.5 ); BOOST_TEST( q.Z() != 5.25, "new z value = " << q.Z() ); } BOOST_AUTO_TEST_SUITE_END()