// Reporter_t.cpp #include "Reporter.h" #include #include #include #include "ReporterTest.h" #include "Message.h" using std::cout; using std::cerr; using std::endl; using std::string; using trf::Reporter; using trf::Message; //********************************************************************** int main( ) { string component = "Reporter"; 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 sender = 5400; int data = 1234; string location = "here"; Message msg(sender, location, data); ReporterTest rtest; rtest.report(msg); assert( rtest.psender == &sender ); assert( rtest.location == location ); assert( rtest.pdata == &data ); assert( rtest.count == 1 ); rtest.report(msg); assert( rtest.psender == &sender ); assert( rtest.location == location ); assert( rtest.pdata == &data ); assert( rtest.count == 2 ); //******************************************************************** cout << ok_prefix << "------------- All tests passed. -------------" << endl; return 0; //******************************************************************** }