#include #include #include #include "JROOT/JRootClass.hh" #include "km3net-dataformat/offline/Head.hh" #include "JAAnet/JHead.hh" #include "Jeep/JPrint.hh" #include "Jeep/JParser.hh" #include "Jeep/JMessage.hh" namespace { using namespace JPP; /** * Print data member. * * \param OUT output stream * \param T data member */ #define PRINT(OUT, T) \ do { OUT \ << std::setw(24) << left << #T << " --> " \ << std::setw(16) << left << (getDataMember(T) != NULL ? getDataMember(T)->GetName() : "?") << std::endl; } while (0) /** * Test data member. * * \param T data member */ #define TEST(T) \ (getClassname(#T) == (getDataMember(T) != NULL ? getDataMember(T)->GetName() : "?")) } /** * \file * * Program to test JROOT::JRootClass. * \author mdejong */ int main(int argc, char **argv) { using namespace std; using namespace JPP; int debug; try { JParser<> zap("Program to test JRootClass."); zap['d'] = make_field(debug) = 3; zap(argc, argv); } catch(const exception& error) { FATAL(error.what() << endl); } if (debug >= debug_t) { PRINT(cout, &JHead::start_run); PRINT(cout, &JHead::detector); PRINT(cout, &JHead::physics); PRINT(cout, &JHead::simul); PRINT(cout, &JHead::cut_primary); PRINT(cout, &JHead::cut_seamuon); PRINT(cout, &JHead::spectrum); PRINT(cout, &JHead::can); PRINT(cout, &JHead::genvol); PRINT(cout, &JHead::coord_origin); PRINT(cout, &JHead::livetime); PRINT(cout, &JHead::seabottom); } ASSERT( TEST(&JHead::start_run) ); ASSERT( TEST(&JHead::detector) ); ASSERT( TEST(&JHead::physics) ); ASSERT( TEST(&JHead::simul) ); ASSERT( TEST(&JHead::cut_primary) ); ASSERT( TEST(&JHead::cut_seamuon) ); ASSERT( TEST(&JHead::spectrum) ); ASSERT( TEST(&JHead::can) ); ASSERT( TEST(&JHead::genvol) ); ASSERT( TEST(&JHead::coord_origin) ); ASSERT( TEST(&JHead::livetime) ); ASSERT( TEST(&JHead::seabottom) ); { const JType type; const JRootClass cls(type); for (const string key : { "start_run", "detector", "physics", "simul", "cut_primary", "cut_seamuon", "spectrum", "can", "genvol", "coord_origin", "livetime", "seabottom" }) { ASSERT( cls.find(key.c_str()).is_valid(), "check validity of " << key); ASSERT(!cls.find(to_upper(key).c_str(), true) .is_valid(), "check invalidity of " << to_upper(key)); ASSERT( cls.find(to_upper(key).c_str(), false).is_valid(), "check validity of " << to_upper(key)); } } return 0; }