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

View File

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