// DetectorID_t.cpp #include "DetectorID.hpp" #include #include #include #include #ifndef DEFECT_NO_STDLIB_NAMESPACES using std::cout; using std::cerr; using std::endl; using std::string; #endif //********************************************************************** int main( ) { string component = "DetectorID"; string ok_prefix = component + " (I): "; string error_prefix = component + " test (E): "; cout << ok_prefix << "---------- Testing component " + component + ". ----------" << endl; // Make sure assert is enabled. bool assert_flag = false; assert ( ( assert_flag = true, assert_flag ) ); if ( ! assert_flag ) { cerr << "Assert is disabled" << endl; return 1; } //******************************************************************** int subid = 1923; DetectorID smt(DetectorID::SMT,subid ); DetectorID cft(DetectorID::CFT,subid ); DetectorID cft_t(cft.get_detector_id() ); assert ( ! (smt == cft) ) ; assert ( smt == smt ) ; assert ( cft == cft_t ) ; assert ( ! ( smt < smt) ) ; assert ( cft < smt ) ; assert ( smt.get_subdetector_type() == DetectorID::SMT ); assert ( cft.get_subdetector_type() == DetectorID::CFT ); assert ( smt.get_subdetector_id() == subid ); assert ( cft.get_subdetector_id() == subid ); subid = 0 ; DetectorID smt1(DetectorID::SMT,subid); assert ( smt1.get_subdetector_id() == subid ); subid = 16777215 ; DetectorID smt2(DetectorID::SMT,subid); assert ( smt2.get_subdetector_id() == subid ); subid = 16777215 ; DetectorID smt3(255,subid); assert ( smt3.get_subdetector_id() == subid ); assert ( smt3.get_subdetector_type() == 255 ); assert ( (int)(smt3.get_detector_id()) == -1 ); cout << "ID is "<< smt3 << endl; DetectorID smt4; assert ( ! (smt4 == smt) ); smt4 = smt ; assert ( smt4 == smt ); // test backward compatibility int id = 101; DetectorID comp(101); assert ( comp.get_subdetector_type() == DetectorID::SMT ); id = 0; DetectorID comp1(0); cout<< comp1<