[Cppunit-devel] Not equals test
Brought to you by:
blep
From: Duane M. <du...@us...> - 2001-09-28 23:35:11
|
I couldnt find an equivalent to CPPUNIT_ASSERT_NOT_EQUAL. That is checking to make sure that some value was NOT some other value. I found this useful in checking error conditions where you want to make sure that the normal non-error condition is NOT returned. Pretty much any other error is fine. If there is a technique for doing this, please let me know. In light of not finding something I added this macro which might be a useful addition to CppUnit. (This should look very familiar. I think I changed two characters :-): namespace CppUnit { namespace TestAssert { template <class T> void assertNotEqual( const T& expected, const T& actual, long lineNumber = Exception::UNKNOWNLINENUMBER, std::string fileName = Exception::UNKNOWNFILENAME ) { if ( assertion_traits<T>::equal(expected,actual) ) // lazy toString conversion... { assertNotEqualImplementation( assertion_traits<T>::toString(expected), assertion_traits<T>::toString(actual), lineNumber, fileName ); } } } #define CPPUNIT_ASSERT_NOT_EQUAL(expected,actual)\ (CppUnit::TestAssert::assertNotEqual ((expected),\ (actual),__LINE__,__FILE__)) } ..Duane |