#define BOOST_TEST_DYN_LINK #include #include #include #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" ); RAT::DB* db = RAT::DB::Get(); RAT::DS::Run run; run.SetRunID(255678); db->BeginOfRun(run); //RAT::DU::Utility::LoadDBAndBeginRun(); -> usefor for RATROOT db->LoadDefaults(); //double z = RAT::GeoUtil::UpdateAVOffsetFromDB(); -> moved to Point3D::BoR Point3D::BeginOfRun(); size_t n = Point3D::GetSystemCount(); BOOST_TEST_MESSAGE( "GlobalFixture setup() checkpoint" ); //BOOST_TEST_MESSAGE( " z = " << z ); // should be 119 for run 255678 BOOST_TEST_MESSAGE( " n = " << n ); for (size_t i = 0; i < n; ++i) { BOOST_TEST_MESSAGE( " " << i << " " << Point3D::GetZOffset(i) << ": " << Point3D::GetSystemName(i) ); } } void teardown() {} }; BOOST_TEST_GLOBAL_FIXTURE( GlobalFixture ); BOOST_AUTO_TEST_SUITE( point3d, *label("geo") ) BOOST_AUTO_TEST_CASE( update_av ) { BOOST_TEST_CHECKPOINT( "about to run update_av checkpoint" ); double z = RAT::GeoUtil::UpdateAVOffsetFromDB(); BOOST_TEST_INFO_SCOPE("update_av: z = " << z); BOOST_TEST( z == 119.0 ); } BOOST_AUTO_TEST_CASE( static_init_test ) { size_t n = Point3D::GetSystemCount(); BOOST_TEST( n == 2 ); BOOST_TEST( !Point3D::HasZOffset(0) ); // innerPMT BOOST_TEST( Point3D::GetZOffset(0) == 0.0 ); BOOST_TEST( Point3D::GetSystemName(0) == "innerPMT" ); BOOST_TEST( Point3D::GetSystemId("innerPMT") == 0 ); BOOST_TEST( Point3D::HasZOffset(1) ); // av BOOST_TEST( Point3D::GetZOffset(1) == 119.0 ); BOOST_TEST( Point3D::GetSystemName(1) == "av" ); BOOST_TEST( Point3D::GetSystemId("av") == 1 ); } 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()