// McParent_t.cpp // Test McParent. #include "McParent.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 = "MCParent"; 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; } //******************************************************************** McParent parent; assert(!parent.from_uds()); parent.set_parent(1); assert(parent.from_uds()); parent.set_parent(23); assert(parent.from_z()); int parentword = parent.get_parentword(); assert(parent.get_parentword()==129); const McParent::ParentList plist = parent.parents(); assert( plist.size()==2); assert( plist.find(23)!= plist.end() ); assert( plist.find(1) != plist.end() ); assert( plist.find(37) == plist.end() ); for (McParent::ParentList::const_iterator it = plist.begin(); it!=plist.end(); ++it){ cout << " Parent= " << *it << endl; } McParent parent2(parentword); assert(parent2.from_uds()); assert(parent2.from_z()); const McParent::ParentList plist2 = parent2.parents(); assert( plist2.size()==2); assert( plist2.find(23)!= plist2.end() ); assert( plist2.find(1) != plist2.end() ); assert( plist2.find(37) == plist2.end() ); //******************************************************************** cout << ok_prefix << "------------- All tests passed. -------------" << endl; return 0; //******************************************************************** }