use CPPUNIT_ASSERT_EQUAL(x,y) instead of CPPUNIT_ASSERT(x==y) to better see test failures

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@54643 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2008-07-15 18:00:49 +00:00
parent fa0584f14d
commit 339e08c704
2 changed files with 65 additions and 75 deletions

View File

@@ -78,40 +78,30 @@ void IntlTestCase::tearDown()
void IntlTestCase::Domain() void IntlTestCase::Domain()
{ {
// _() searches all domains by default: // _() searches all domains by default:
CPPUNIT_ASSERT( _("&Open bogus file") == "&Ouvrir un fichier" ); WX_ASSERT_STR_EQUAL( "&Ouvrir un fichier", _("&Open bogus file") );
// search in our domain only: // search in our domain only:
CPPUNIT_ASSERT( wxGetTranslation("&Open bogus file", "internat") == WX_ASSERT_STR_EQUAL( "&Ouvrir un fichier", wxGetTranslation("&Open bogus file", "internat") );
"&Ouvrir un fichier" );
// search in a domain that doesn't have this string: // search in a domain that doesn't have this string:
CPPUNIT_ASSERT( wxGetTranslation("&Open bogus file", "BogusDomain") == WX_ASSERT_STR_EQUAL( "&Open bogus file", wxGetTranslation("&Open bogus file", "BogusDomain") );
"&Open bogus file" );
} }
void IntlTestCase::Headers() void IntlTestCase::Headers()
{ {
CPPUNIT_ASSERT( m_locale->GetHeaderValue("Project-Id-Version") == WX_ASSERT_STR_EQUAL( "wxWindows 2.0 i18n sample", m_locale->GetHeaderValue("Project-Id-Version") );
"wxWindows 2.0 i18n sample" ); WX_ASSERT_STR_EQUAL( "1999-01-13 18:19+0100", m_locale->GetHeaderValue("POT-Creation-Date") );
CPPUNIT_ASSERT( m_locale->GetHeaderValue("POT-Creation-Date") == WX_ASSERT_STR_EQUAL( "YEAR-MO-DA HO:MI+ZONE", m_locale->GetHeaderValue("PO-Revision-Date") );
"1999-01-13 18:19+0100" ); WX_ASSERT_STR_EQUAL( "Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr>", m_locale->GetHeaderValue("Last-Translator") );
CPPUNIT_ASSERT( m_locale->GetHeaderValue("PO-Revision-Date") == WX_ASSERT_STR_EQUAL( "1.0", m_locale->GetHeaderValue("MIME-Version") );
"YEAR-MO-DA HO:MI+ZONE" ); WX_ASSERT_STR_EQUAL( "text/plain; charset=iso-8859-1", m_locale->GetHeaderValue("Content-Type") );
CPPUNIT_ASSERT( m_locale->GetHeaderValue("Last-Translator") == WX_ASSERT_STR_EQUAL( "8bit", m_locale->GetHeaderValue("Content-Transfer-Encoding") );
"Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr>" );
CPPUNIT_ASSERT( m_locale->GetHeaderValue("MIME-Version") ==
"1.0" );
CPPUNIT_ASSERT( m_locale->GetHeaderValue("Content-Type") ==
"text/plain; charset=iso-8859-1" );
CPPUNIT_ASSERT( m_locale->GetHeaderValue("Content-Transfer-Encoding") ==
"8bit" );
// check that it fails with a bogus domain: // check that it fails with a bogus domain:
CPPUNIT_ASSERT( m_locale->GetHeaderValue("POT-Creation-Date", "Bogus") == WX_ASSERT_STR_EQUAL( "", m_locale->GetHeaderValue("POT-Creation-Date", "Bogus") );
"" );
// and that it fails for nonexisting header: // and that it fails for nonexisting header:
CPPUNIT_ASSERT( m_locale->GetHeaderValue("X-Not-Here") == "" ); WX_ASSERT_STR_EQUAL( "", m_locale->GetHeaderValue("X-Not-Here") );
} }
#endif // wxUSE_INTL #endif // wxUSE_INTL

View File

@@ -95,13 +95,13 @@ void StdStringTestCase::StdConstructors()
s7(s3.begin(), s3.begin() + 8); s7(s3.begin(), s3.begin() + 8);
wxString s8(s1, 4, 8); wxString s8(s1, 4, 8);
CPPUNIT_ASSERT( s1 == _T("abcdefgh") ); WX_ASSERT_STR_EQUAL( _T("abcdefgh"), s1 );
CPPUNIT_ASSERT( s2 == s1 ); CPPUNIT_ASSERT_EQUAL( s1, s2 );
CPPUNIT_ASSERT( s4 == _T("aaaaaaaa") ); WX_ASSERT_STR_EQUAL( _T("aaaaaaaa"), s4 );
CPPUNIT_ASSERT( s5 == _T("abcdefgh") ); WX_ASSERT_STR_EQUAL( _T("abcdefgh"), s5 );
CPPUNIT_ASSERT( s6 == s1 ); CPPUNIT_ASSERT_EQUAL( s1, s6 );
CPPUNIT_ASSERT( s7 == s1 ); CPPUNIT_ASSERT_EQUAL( s1, s7 );
CPPUNIT_ASSERT( s8 == _T("efgh") ); WX_ASSERT_STR_EQUAL( _T("efgh"), s8 );
const char *pc = s1.c_str(); const char *pc = s1.c_str();
WX_ASSERT_STR_EQUAL( "bcd", wxString(pc + 1, pc + 4) ); WX_ASSERT_STR_EQUAL( "bcd", wxString(pc + 1, pc + 4) );
@@ -133,12 +133,12 @@ void StdStringTestCase::StdAppend()
s5.append(1, (unsigned char)'y'); s5.append(1, (unsigned char)'y');
s6.append(s1.begin() + 3, s1.end()); s6.append(s1.begin() + 3, s1.end());
CPPUNIT_ASSERT( s1 == _T("abcdef") ); WX_ASSERT_STR_EQUAL( _T("abcdef"), s1 );
CPPUNIT_ASSERT( s2 == _T("abcdef") ); WX_ASSERT_STR_EQUAL( _T("abcdef"), s2 );
CPPUNIT_ASSERT( s3 == _T("abcdef") ); WX_ASSERT_STR_EQUAL( _T("abcdef"), s3 );
CPPUNIT_ASSERT( s4 == _T("abcabcdef") ); WX_ASSERT_STR_EQUAL( _T("abcabcdef"), s4 );
CPPUNIT_ASSERT( s5 == _T("abcaaaxxy") ); WX_ASSERT_STR_EQUAL( _T("abcaaaxxy"), s5 );
CPPUNIT_ASSERT( s6 == _T("abcdef") ); WX_ASSERT_STR_EQUAL( _T("abcdef"), s6 );
const char *pc = s1.c_str() + 2; const char *pc = s1.c_str() + 2;
s7.append(pc, pc + 4); s7.append(pc, pc + 4);
@@ -153,8 +153,8 @@ void StdStringTestCase::StdAppend()
s7.append(_T("def")); s7.append(_T("def"));
s8.append(_T("defgh"), 3); s8.append(_T("defgh"), 3);
CPPUNIT_ASSERT( s7 == wxString(_T("null\0timedef"), 12) ); CPPUNIT_ASSERT_EQUAL( wxString(_T("null\0timedef"), 12), s7 );
CPPUNIT_ASSERT( s8 == wxString(_T("null\0timedef"), 12) ); CPPUNIT_ASSERT_EQUAL( wxString(_T("null\0timedef"), 12), s8 );
} }
void StdStringTestCase::StdAssign() void StdStringTestCase::StdAssign()
@@ -169,12 +169,12 @@ void StdStringTestCase::StdAssign()
s5.assign(3, _T('a')); s5.assign(3, _T('a'));
s6.assign(s1.begin() + 1, s1.end()); s6.assign(s1.begin() + 1, s1.end());
CPPUNIT_ASSERT( s1 == _T("def") ); WX_ASSERT_STR_EQUAL( _T("def"), s1 );
CPPUNIT_ASSERT( s2 == _T("def") ); WX_ASSERT_STR_EQUAL( _T("def"), s2 );
CPPUNIT_ASSERT( s3 == _T("def") ); WX_ASSERT_STR_EQUAL( _T("def"), s3 );
CPPUNIT_ASSERT( s4 == _T("def") ); WX_ASSERT_STR_EQUAL( _T("def"), s4 );
CPPUNIT_ASSERT( s5 == _T("aaa") ); WX_ASSERT_STR_EQUAL( _T("aaa"), s5 );
CPPUNIT_ASSERT( s6 == _T("ef") ); WX_ASSERT_STR_EQUAL( _T("ef"), s6 );
const char *pc = s1.c_str(); const char *pc = s1.c_str();
s7.assign(pc, pc + 2); s7.assign(pc, pc + 2);
@@ -228,11 +228,11 @@ void StdStringTestCase::StdErase()
wxString::iterator it2 = s4.erase(s4.begin() + 4, s4.begin() + 6); wxString::iterator it2 = s4.erase(s4.begin() + 4, s4.begin() + 6);
wxString::iterator it3 = s7.erase(s7.begin() + 4, s7.begin() + 8); wxString::iterator it3 = s7.erase(s7.begin() + 4, s7.begin() + 8);
CPPUNIT_ASSERT( s1 == _T("acdefgh") ); WX_ASSERT_STR_EQUAL( _T("acdefgh"), s1 );
CPPUNIT_ASSERT( s2 == _T("abcd") ); WX_ASSERT_STR_EQUAL( _T("abcd"), s2 );
CPPUNIT_ASSERT( s3 == _T("ac") ); WX_ASSERT_STR_EQUAL( _T("ac"), s3 );
CPPUNIT_ASSERT( s4 == _T("abcdghi") ); WX_ASSERT_STR_EQUAL( _T("abcdghi"), s4 );
CPPUNIT_ASSERT( s7 == _T("zabc") ); WX_ASSERT_STR_EQUAL( _T("zabc"), s7 );
CPPUNIT_ASSERT( *it == _T('c') ); CPPUNIT_ASSERT( *it == _T('c') );
CPPUNIT_ASSERT( *it2 == _T('g') ); CPPUNIT_ASSERT( *it2 == _T('g') );
CPPUNIT_ASSERT( it3 == s7.end() ); CPPUNIT_ASSERT( it3 == s7.end() );
@@ -383,21 +383,21 @@ void StdStringTestCase::StdInsert()
s7.insert(s7.begin(), s9.begin(), s9.end() - 1); s7.insert(s7.begin(), s9.begin(), s9.end() - 1);
s8.insert(s8.begin(), 2, _T('c')); s8.insert(s8.begin(), 2, _T('c'));
CPPUNIT_ASSERT( s1 == _T("accaaa") ); WX_ASSERT_STR_EQUAL( _T("accaaa") , s1 );
CPPUNIT_ASSERT( s2 == _T("aacdeaa") ); WX_ASSERT_STR_EQUAL( _T("aacdeaa") , s2 );
CPPUNIT_ASSERT( s3 == _T("aacdefgaa") ); WX_ASSERT_STR_EQUAL( _T("aacdefgaa"), s3 );
CPPUNIT_ASSERT( s4 == _T("aafgaa") ); WX_ASSERT_STR_EQUAL( _T("aafgaa") , s4 );
CPPUNIT_ASSERT( s5 == _T("accaaa") ); WX_ASSERT_STR_EQUAL( _T("accaaa") , s5 );
CPPUNIT_ASSERT( s6 == _T("aaaXa") ); WX_ASSERT_STR_EQUAL( _T("aaaXa") , s6 );
CPPUNIT_ASSERT( s7 == _T("cdefaaaa") ); WX_ASSERT_STR_EQUAL( _T("cdefaaaa") , s7 );
CPPUNIT_ASSERT( s8 == _T("ccaaaa") ); WX_ASSERT_STR_EQUAL( _T("ccaaaa") , s8 );
s1 = s2 = s3 = _T("aaaa"); s1 = s2 = s3 = _T("aaaa");
s1.insert(0, _T("ccc"), 2); s1.insert(0, _T("ccc"), 2);
s2.insert(4, _T("ccc"), 2); s2.insert(4, _T("ccc"), 2);
CPPUNIT_ASSERT( s1 == _T("ccaaaa") ); WX_ASSERT_STR_EQUAL( _T("ccaaaa"), s1 );
CPPUNIT_ASSERT( s2 == _T("aaaacc") ); WX_ASSERT_STR_EQUAL( _T("aaaacc"), s2 );
} }
void StdStringTestCase::StdReplace() void StdStringTestCase::StdReplace()
@@ -416,13 +416,13 @@ void StdStringTestCase::StdReplace()
s6.replace(0, 123, s9, 0, 123); s6.replace(0, 123, s9, 0, 123);
s7.replace(2, 7, s9); s7.replace(2, 7, s9);
CPPUNIT_ASSERT( s1 == _T("QWErtyuIopopop") ); WX_ASSERT_STR_EQUAL( _T("QWErtyuIopopop"), s1 );
CPPUNIT_ASSERT( s2 == _T("QWERTYUIOPWWWW") ); WX_ASSERT_STR_EQUAL( _T("QWERTYUIOPWWWW"), s2 );
CPPUNIT_ASSERT( s3 == _T("QwertyUIOP") ); WX_ASSERT_STR_EQUAL( _T("QwertyUIOP") , s3 );
CPPUNIT_ASSERT( s4 == _T("QwertYUIOP") ); WX_ASSERT_STR_EQUAL( _T("QwertYUIOP") , s4 );
CPPUNIT_ASSERT( s5 == _T("QertyRTYUIOP") ); WX_ASSERT_STR_EQUAL( _T("QertyRTYUIOP") , s5 );
CPPUNIT_ASSERT( s6 == s9); CPPUNIT_ASSERT_EQUAL( s9, s6 );
CPPUNIT_ASSERT( s7 == _T("QWwertyP") ); WX_ASSERT_STR_EQUAL( _T("QWwertyP"), s7 );
} }
void StdStringTestCase::StdRFind() void StdStringTestCase::StdRFind()
@@ -484,10 +484,10 @@ void StdStringTestCase::StdResize()
s3.resize( 14, _T(' ') ); s3.resize( 14, _T(' ') );
s4.resize( 14, _T('W') ); s4.resize( 14, _T('W') );
CPPUNIT_ASSERT( s1 == _T("abcABCdefDEF") ); WX_ASSERT_STR_EQUAL( _T("abcABCdefDEF"), s1 );
CPPUNIT_ASSERT( s2 == _T("abcABCdefD") ); WX_ASSERT_STR_EQUAL( _T("abcABCdefD"), s2 );
CPPUNIT_ASSERT( s3 == _T("abcABCdefDEF ") ); WX_ASSERT_STR_EQUAL( _T("abcABCdefDEF "), s3 );
CPPUNIT_ASSERT( s4 == _T("abcABCdefDEFWW") ); WX_ASSERT_STR_EQUAL( _T("abcABCdefDEFWW"), s4 );
wxString s = wxString s =
wxString::FromUTF8("\xd0\x9f\xd1\x80\xd0\xb8\xd0\xb2\xd0\xb5\xd1\x82"); wxString::FromUTF8("\xd0\x9f\xd1\x80\xd0\xb8\xd0\xb2\xd0\xb5\xd1\x82");
@@ -546,16 +546,16 @@ void StdStringTestCase::StdConversion()
wxStdWideString strStdWide(L"std::wstring value"); wxStdWideString strStdWide(L"std::wstring value");
wxString s1(strStd); wxString s1(strStd);
CPPUNIT_ASSERT( s1 == "std::string value" ); WX_ASSERT_STR_EQUAL( "std::string value", s1 );
wxString s2(strStdWide); wxString s2(strStdWide);
CPPUNIT_ASSERT( s2 == "std::wstring value" ); WX_ASSERT_STR_EQUAL( "std::wstring value", s2 );
wxString s3; wxString s3;
s3 = strStd; s3 = strStd;
CPPUNIT_ASSERT( s3 == "std::string value" ); WX_ASSERT_STR_EQUAL( "std::string value", s3 );
s3 = strStdWide; s3 = strStdWide;
CPPUNIT_ASSERT( s3 == "std::wstring value" ); WX_ASSERT_STR_EQUAL( "std::wstring value", s3 );
wxString s4("hello"); wxString s4("hello");
@@ -563,10 +563,10 @@ void StdStringTestCase::StdConversion()
// because it conflicts with conversion to const char*/wchar_t*: // because it conflicts with conversion to const char*/wchar_t*:
#if wxUSE_STL #if wxUSE_STL
std::string s5 = s4; std::string s5 = s4;
CPPUNIT_ASSERT( s5 == "hello" ); WX_ASSERT_STR_EQUAL( "hello", s5 );
wxStdWideString s6 = s4; wxStdWideString s6 = s4;
CPPUNIT_ASSERT( s6 == "hello" ); WX_ASSERT_STR_EQUAL( "hello", s6 );
#endif #endif
std::string s7(s4); std::string s7(s4);