// CandidateLayer_t.cpp #include "CandidateLayer.h" #include #include #include #include "trfutil/trfstream.h" #include "trflayer/LayerTest.h" #include "trffit/AddFitterTest.h" #include "trfbase/PropStat.h" #include "trfbase/PropDirectedTest.h" #include "trfbase/HitTest.h" #include "trffit/AddFitter.h" using std::cout; using std::cerr; using std::endl; using std::string; namespace trf { class HTrack; } // end namespace trf using namespace trf; //********************************************************************** int main( ) { string component = "CandidateLayer"; 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; } //******************************************************************** cout << trf_format; cout << ok_prefix << "Create candidate layer." << endl; LayerTest layer(1.0); PropTest prop; AddFitterTest fit(0); CandidateLayer cnl(layer,prop,fit); cout << cnl << endl; assert( cnl.is_valid() ); //******************************************************************** cout << ok_prefix << "Test reference fetching." << endl; cout << cnl.get_layer() << endl; cout << cnl.get_propagator() << endl; cout << cnl.get_fitter() << endl; //******************************************************************** cout << ok_prefix << "Create an empty candidate." << endl; CandidateLayer empty; cout << empty << endl; assert( ! empty.is_valid() ); //******************************************************************** cout << ok_prefix << "Check equality and inequality." << endl; LayerTest layer2(2.0); PropTest prop2; AddFitterTest fit2(0); CandidateLayer cnl1(layer,prop,fit); CandidateLayer cnl2(layer2,prop,fit); CandidateLayer cnl3(layer,prop2,fit); CandidateLayer cnl4(layer,prop,fit2); assert( empty != cnl ); assert( ! (empty == cnl ) ); assert( cnl != empty ); assert( cnl != cnl2 ); assert( cnl3 != cnl ); assert( ! ( cnl == cnl4 ) ); assert( cnl == cnl1 ); assert( cnl1 == cnl ); assert( ! ( cnl != cnl1 ) ); //******************************************************************** cout << ok_prefix << "Check ordering." << endl; assert( ! ( cnl < cnl1 ) ); assert( ! ( cnl1 < cnl ) ); assert( cnl < cnl2 || cnl2 < cnl ); //******************************************************************** cout << ok_prefix << "------------- All tests passed. -------------" << endl; return 0; //******************************************************************** }