Re: [Cppunit-devel] Partial answer: 2.3) Why does the test ExceptionTest.testAssignment failed in Cp
Brought to you by:
blep
From: Baptiste L. <bl...@cl...> - 2001-10-06 08:22:50
|
Thanks for pointing that out Phil. I went a little further, and while the operator =() does weird stuff it does the job. When checkIsSame() is called, members of the original and assigned exception are equal (m_message members that are used by CppUnit::Exception::what() have the same value). I tracked down the problem, and it occurs in checkIsSame(): void ExceptionTest::checkIsSame( CppUnit::Exception &e, CppUnit::Exception &other ) { std::string eWhat( e.what() ); std::string otherWhat( other.what() ); --- 004054DA mov esi,esp 004054DC lea eax,[ebp-38h] 004054DF push eax 004054E0 mov ecx,dword ptr [ebp+0Ch] 004054E3 mov edx,dword ptr [ecx] 004054E5 mov edi,esp 004054E7 mov ecx,dword ptr [ebp+0Ch] 004054EA call dword ptr [edx+4] // here std::exception::what() is called instead of CppUnit::Exception::what() which returns the m_message member. // The weird stuff is that e.what() does call CppUnit::Exception::what() correctly... --- CPPUNIT_ASSERT_EQUAL( eWhat, otherWhat ); CPPUNIT_ASSERT( e.sourceLine() == other.sourceLine() ); } No matter how I twist think around, for other, it is always std::exception::what() that is called ! // Inverting the order of initialisation doesn't change a thing... const char *otherWhat = other.what(); const char *eWhat = e.what(); CPPUNIT_ASSERT_EQUAL( std::string(eWhat), std::string(otherWhat) ); Any idea ? Baptiste. ----- Original Message ----- From: "Phil Taylor" <phi...@ts...> To: <cpp...@li...> Sent: Thursday, October 04, 2001 2:57 PM Subject: [Cppunit-devel] Partial answer: 2.3) Why does the test ExceptionTest.testAssignment failed in CppUnit test > The implementation of the assignment operator for std::exception in > MSVCRT seems to be cause of the problem. Comment out the > SuperClass::operator= (other) call in Exception::operator=(Exception&) > and the test now passes. > > Examination of MSVCRT disassembly yields some odd-looking (shortcut?) > behavior. It looks as though exception::operator=(exception&) resets > itself by calling its own destructor (memory is not freed) then calls > exception(exception&) to complete the assignment. > > I can't progress the problem any further at this time but the > information above may be of some assistance. > > Regards, > Phil > > > _______________________________________________ > Cppunit-devel mailing list > Cpp...@li... > https://lists.sourceforge.net/lists/listinfo/cppunit-devel > |