Unit tests update

This commit is contained in:
Markus Gans 2018-04-02 23:14:58 +02:00
parent 17a6e5b889
commit f05b850fbf
2 changed files with 14 additions and 10 deletions

View File

@ -43,10 +43,10 @@ void check_c_string ( const char* s1
, const char* s2 , const char* s2
, CppUnit::SourceLine sourceLine ) , CppUnit::SourceLine sourceLine )
{ {
if ( s1 == 0 && s2 == 0 ) if ( s1 == 0 && s2 == 0 ) // Strings are equal
return; return;
if ( s1 && s2 && std::strcmp (s1, s2) == 0 ) if ( s1 && s2 && std::strcmp (s1, s2) == 0 ) // Strings are equal
return; return;
::CppUnit::Asserter::fail ("Strings are not equal", sourceLine); ::CppUnit::Asserter::fail ("Strings are not equal", sourceLine);
@ -101,16 +101,23 @@ void FOptiAttrTest::classNameTest()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FOptiAttrTest::noArgumentTest() void FOptiAttrTest::noArgumentTest()
{ {
FOptiAttr::char_data* ch = new FOptiAttr::char_data();
FOptiAttr oa; FOptiAttr oa;
oa.initialize(); oa.initialize();
// isNormal test // isNormal test
FOptiAttr::char_data* ch = new FOptiAttr::char_data();
CPPUNIT_ASSERT ( ! oa.isNormal(ch) ); CPPUNIT_ASSERT ( ! oa.isNormal(ch) );
ch->fg_color = fc::Default; ch->fg_color = fc::Default;
CPPUNIT_ASSERT ( ! oa.isNormal(ch) ); CPPUNIT_ASSERT ( ! oa.isNormal(ch) );
ch->bg_color = fc::Default; ch->bg_color = fc::Default;
CPPUNIT_ASSERT ( oa.isNormal(ch) ); CPPUNIT_ASSERT ( oa.isNormal(ch) );
// Null test
FOptiAttr::char_data* ch_null = 0;
CPPUNIT_ASSERT ( oa.changeAttribute(ch, ch) == 0 );
CPPUNIT_ASSERT_CSTRING ( oa.changeAttribute(ch, ch_null), C_STR("") );
CPPUNIT_ASSERT_CSTRING ( oa.changeAttribute(ch_null, ch), C_STR("") );
CPPUNIT_ASSERT_CSTRING ( oa.changeAttribute(ch_null, ch_null), C_STR("") );
delete ch; delete ch;
} }

View File

@ -43,13 +43,10 @@ void check_c_string ( const char* s1
, const char* s2 , const char* s2
, CppUnit::SourceLine sourceLine ) , CppUnit::SourceLine sourceLine )
{ {
if ( s1 == 0 && s2 == 0 ) if ( s1 == 0 && s2 == 0 ) // Strings are equal
return; return;
if ( s1 && s2 && std::strcmp (s1, s2) == 0 ) if ( s1 && s2 && std::strcmp (s1, s2) == 0 ) // Strings are equal
return;
if ( std::strcmp (s1, s2) == 0 )
return; return;
::CppUnit::Asserter::fail ("Strings are not equal", sourceLine); ::CppUnit::Asserter::fail ("Strings are not equal", sourceLine);