// PropDirected_t.cpp #include "PropDirected.h" #include #include #include #include "PropDirectedTest.h" #include "VTrack.h" #include "ETrack.h" #include "TrackVector.h" #include "SurfTest.h" #include "objstream/StdObjStream.hpp" using std::cout; using std::cerr; using std::endl; using std::string; using std::ostringstream; using std::istringstream; using namespace trf; //********************************************************************** int main( ) { string ok_prefix = "PropDirected test (I): "; string error_prefix = "PropDirected test (E): "; cout << ok_prefix << "------- Testing component PropDirected. -------" << 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 << ok_prefix << "Test constructor." << endl; ObjTable::register_type(); ObjTable::register_type(); PropTest tprop; cout << tprop << endl; //******************************************************************** cout << ok_prefix << "Test backward VTrack propagation." << endl; tprop.set_direction(Propagator::BACKWARD); SurfTest tsrf1(1); VTrack trv1( SurfacePtr(tsrf1.new_pure_surface()) ); SurfTest tsrf3(3); VTrack trv2 = trv1; VTrack trv3 = trv2; cout << trv3 << endl; tprop.vec_prop(trv3,tsrf3); cout << trv3 << endl; assert( *trv3.get_surface() == tsrf3 ); assert( trv3.get_vector()(1) < trv2.get_vector()(1) ); //******************************************************************** cout << ok_prefix << "Test backward ETrack propagation." << endl; tprop.set_direction(Propagator::BACKWARD); SurfTest tsrf2(2); ETrack tre2( SurfacePtr(tsrf2.new_pure_surface()) ); TrackError err; err(0,0) = 0.01; err(1,1) = 0.02; err(2,2) = 0.03; err(3,3) = 0.04; err(4,4) = 0.05; tre2.set_error(err); ETrack tre3 = tre2; cout << tre3 << endl; tprop.err_prop(tre3,tsrf3); cout << tre3 << endl; assert( *tre3.get_surface() == tsrf3 ); assert( tre3.get_vector()(1) < tre2.get_vector()(1) ); //******************************************************************** cout << ok_prefix << "Read object data." << endl; { string istring = "[ ptest PropTest dir=\"forward_move\" ]"; cout << istring << endl; istringstream isstrm(istring); { StdObjStream obstr(isstrm); string name = obstr.read_object(); assert( name == "ptest" ); const PropTest* pobj; ObjTable::get_object("ptest",pobj); assert( pobj != 0 ); cout << *pobj << endl; assert( pobj->get_type() == PropTest::get_static_type() ); assert( pobj->get_direction() == Propagator::FORWARD_MOVE ); assert( pobj->get_direction() != Propagator::FORWARD ); } } //******************************************************************** cout << ok_prefix << "------------- All tests passed. -------------" << endl; return 0; //******************************************************************** }