// Message_t.cpp #include "Message.h" #include #include #include using std::cout; using std::cerr; using std::endl; using std::string; using trf::AbsMessage; using trf::DataMessage; using trf::SenderMessage; using trf::Message; //********************************************************************** int main( ) { string component = "Message"; 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 isnd = 1000; string loc = "here"; double data = 12.345; Message msg(isnd, loc, data); assert ( &msg.sender() == &isnd ); assert ( msg.location() == loc ); assert ( msg.data() == data ); AbsMessage* pmsg = &msg; assert ( pmsg->sender_address() == &isnd ); assert ( pmsg->location() == loc ); assert ( dynamic_cast*>(pmsg) != 0 ); assert ( dynamic_cast*>(pmsg) != 0 ); //******************************************************************** cout << ok_prefix << "------------- All tests passed. -------------" << endl; return 0; //******************************************************************** }