#define WXTEST_FAIL_WITH_CONDITION(suiteName, Condition, testMethod) \
WXTEST_ANY_WITH_CONDITION(suiteName, Condition, testMethod, CPPUNIT_TEST_FAIL(testMethod))
-// Use this macro to compare a wxString with a literal string.
-#define WX_ASSERT_STR_EQUAL(p, s) CPPUNIT_ASSERT_EQUAL(wxString(p), s)
+CPPUNIT_NS_BEGIN
+
+// provide an overload of cppunit assertEquals(T, T) which can be used to
+// compare wxStrings directly with C strings
+inline void
+assertEquals(const char *expected,
+ const wxString& actual,
+ CppUnit::SourceLine sourceLine,
+ const std::string& message)
+{
+ assertEquals(wxString(expected), actual, sourceLine, message);
+}
+
+inline void
+assertEquals(const wchar_t *expected,
+ const wxString& actual,
+ CppUnit::SourceLine sourceLine,
+ const std::string& message)
+{
+ assertEquals(wxString(expected), actual, sourceLine, message);
+}
+
+// and another to be able to specify (usually literal) ints as expected values
+// for functions returning size_t
+inline void
+assertEquals(int expected,
+ size_t actual,
+ CppUnit::SourceLine sourceLine,
+ const std::string& message)
+{
+ assertEquals(size_t(expected), actual, sourceLine, message);
+}
+
+// and another, slightly different, for checking that result of potentially
+// different time_t type is the same as given time_t value
+inline void
+assertEquals(time_t expected,
+ long actual,
+ CppUnit::SourceLine sourceLine,
+ const std::string& message)
+{
+ assertEquals(expected, time_t(actual), sourceLine, message);
+}
-// Use this macro to compare a size_t with a literal integer
-#define WX_ASSERT_SIZET_EQUAL(n, m) CPPUNIT_ASSERT_EQUAL(((size_t)n), m)
+CPPUNIT_NS_END
// Use this macro to compare a wxArrayString with the pipe-separated elements
// of the given string
} \
}
-// Use this macro to compare the expected time_t value with the result of not
-// necessarily time_t type
-#define WX_ASSERT_TIME_T_EQUAL(t, n) CPPUNIT_ASSERT_EQUAL((t), (time_t)(n))
-
// Use this macro to assert with the given formatted message (it should contain
// the format string and arguments in a separate pair of parentheses)
#define WX_ASSERT_MESSAGE(msg, cond) \
CPPUNIT_ASSERT(resultEmpty.empty());
bufmt = wxBase64Decode(resultEmpty);
- WX_ASSERT_SIZET_EQUAL(0, bufmt.GetDataLen());
+ CPPUNIT_ASSERT_EQUAL(0, bufmt.GetDataLen());
}
void Base64TestCase::EncodeDecodeA()
CPPUNIT_ASSERT_EQUAL(wxString("QQ=="), str);
wxMemoryBuffer buf = wxBase64Decode(str);
- WX_ASSERT_SIZET_EQUAL(1, buf.GetDataLen());
+ CPPUNIT_ASSERT_EQUAL(1, buf.GetDataLen());
CPPUNIT_ASSERT_EQUAL('A', *(char *)buf.GetData());
}
CPPUNIT_ASSERT_EQUAL(wxString("QUI="), str);
wxMemoryBuffer buf = wxBase64Decode(str);
- WX_ASSERT_SIZET_EQUAL(2, buf.GetDataLen());
+ CPPUNIT_ASSERT_EQUAL(2, buf.GetDataLen());
CPPUNIT_ASSERT_EQUAL('A', buf[0]);
CPPUNIT_ASSERT_EQUAL('B', buf[1]);
}
CPPUNIT_ASSERT_EQUAL(wxString("QUJD"), str);
wxMemoryBuffer buf = wxBase64Decode(str);
- WX_ASSERT_SIZET_EQUAL(3, buf.GetDataLen());
+ CPPUNIT_ASSERT_EQUAL(3, buf.GetDataLen());
CPPUNIT_ASSERT_EQUAL('A', buf[0]);
CPPUNIT_ASSERT_EQUAL('B', buf[1]);
CPPUNIT_ASSERT_EQUAL('C', buf[2]);
CPPUNIT_ASSERT_EQUAL(wxString("QUJDRA=="), str);
wxMemoryBuffer buf = wxBase64Decode(str);
- WX_ASSERT_SIZET_EQUAL(4, buf.GetDataLen());
+ CPPUNIT_ASSERT_EQUAL(4, buf.GetDataLen());
CPPUNIT_ASSERT_EQUAL('A', buf[0]);
CPPUNIT_ASSERT_EQUAL('B', buf[1]);
CPPUNIT_ASSERT_EQUAL('C', buf[2]);
rc = wxBase64Decode(NULL, 0, "one two!", wxNO_LEN,
wxBase64DecodeMode_Strict, &posErr);
CPPUNIT_ASSERT_EQUAL( wxCONV_FAILED, rc);
- WX_ASSERT_SIZET_EQUAL( 3, posErr );
+ CPPUNIT_ASSERT_EQUAL( 3, posErr );
rc = wxBase64Decode(NULL, 0, "one two!", wxNO_LEN,
wxBase64DecodeMode_SkipWS, &posErr);
CPPUNIT_ASSERT_EQUAL( wxCONV_FAILED, rc);
- WX_ASSERT_SIZET_EQUAL( 7, posErr );
+ CPPUNIT_ASSERT_EQUAL( 7, posErr );
rc = wxBase64Decode(NULL, 0, "? QQ==", wxNO_LEN,
wxBase64DecodeMode_SkipWS, &posErr);
CPPUNIT_ASSERT_EQUAL( wxCONV_FAILED, rc);
- WX_ASSERT_SIZET_EQUAL( 0, posErr );
+ CPPUNIT_ASSERT_EQUAL( 0, posErr );
posErr = (size_t)-1;
rc = wxBase64Decode(NULL, 0, " QQ==", wxNO_LEN,
wxBase64DecodeMode_SkipWS, &posErr);
- WX_ASSERT_SIZET_EQUAL( 1, rc );
- WX_ASSERT_SIZET_EQUAL( -1, posErr );
+ CPPUNIT_ASSERT_EQUAL( 1, rc );
+ CPPUNIT_ASSERT_EQUAL( -1, posErr );
rc = wxBase64Decode(NULL, 0, "? QQ==", wxNO_LEN,
wxBase64DecodeMode_Relaxed, &posErr);
- WX_ASSERT_SIZET_EQUAL( 1, rc );
- WX_ASSERT_SIZET_EQUAL( -1, posErr );
+ CPPUNIT_ASSERT_EQUAL( 1, rc );
+ CPPUNIT_ASSERT_EQUAL( -1, posErr );
CPPUNIT_ASSERT( !wxBase64Decode("wxGetApp()").GetDataLen() );
}
Line_Max
};
- WX_ASSERT_SIZET_EQUAL( Line_Max, usageLines.size() );
- WX_ASSERT_STR_EQUAL("Verbosity options", usageLines[Line_Text_Verbosity]);
- WX_ASSERT_STR_EQUAL("", usageLines[Line_Text_Dummy1]);
- WX_ASSERT_STR_EQUAL("Even more usage text", usageLines[Line_Text_Dummy2]);
- WX_ASSERT_STR_EQUAL("", usageLines[Line_Last]);
+ CPPUNIT_ASSERT_EQUAL(Line_Max, usageLines.size());
+ CPPUNIT_ASSERT_EQUAL("Verbosity options", usageLines[Line_Text_Verbosity]);
+ CPPUNIT_ASSERT_EQUAL("", usageLines[Line_Text_Dummy1]);
+ CPPUNIT_ASSERT_EQUAL("Even more usage text", usageLines[Line_Text_Dummy2]);
+ CPPUNIT_ASSERT_EQUAL("", usageLines[Line_Last]);
}
CPPUNIT_ASSERT( m_text->IsEmpty() );
m_text->SetValue("foo");
- WX_ASSERT_STR_EQUAL( "foo", m_text->GetValue() );
+ CPPUNIT_ASSERT_EQUAL( "foo", m_text->GetValue() );
m_text->SetValue("");
CPPUNIT_ASSERT( m_text->IsEmpty() );
m_text->SetValue("hi");
- WX_ASSERT_STR_EQUAL( "hi", m_text->GetValue() );
+ CPPUNIT_ASSERT_EQUAL( "hi", m_text->GetValue() );
m_text->SetValue("bye");
- WX_ASSERT_STR_EQUAL( "bye", m_text->GetValue() );
+ CPPUNIT_ASSERT_EQUAL( "bye", m_text->GetValue() );
}
void TextCtrlTestCase::TextChangeEvents()
long ticks = (dt.GetValue() / 1000).ToLong() + TZ_LOCAL.GetOffset();
if ( dt.IsDST() )
ticks += 3600;
- WX_ASSERT_TIME_T_EQUAL( d.gmticks, ticks + tzOffset );
+ CPPUNIT_ASSERT_EQUAL( d.gmticks, ticks + tzOffset );
dt = d.DT().FromTimezone(wxDateTime::UTC);
ticks = (dt.GetValue() / 1000).ToLong();
- WX_ASSERT_TIME_T_EQUAL( d.gmticks, ticks );
+ CPPUNIT_ASSERT_EQUAL( d.gmticks, ticks );
}
}
);
// compare result with expected string
- WX_ASSERT_STR_EQUAL( fnt.expected, fn.GetFullPath(fnt.fmt) );
+ CPPUNIT_ASSERT_EQUAL( fnt.expected, fn.GetFullPath(fnt.fmt) );
}
}
for ( size_t n = 0; n < WXSIZEOF(charsets); n++ )
{
wxFontEncoding enc = fmap.CharsetToEncoding(charsets[n]);
- WX_ASSERT_STR_EQUAL( names[n], fmap.GetEncodingName(enc).Lower() );
- WX_ASSERT_STR_EQUAL( descriptions[n], fmap.GetEncodingDescription(enc) );
+ CPPUNIT_ASSERT_EQUAL( names[n], fmap.GetEncodingName(enc).Lower() );
+ CPPUNIT_ASSERT_EQUAL( descriptions[n], fmap.GetEncodingDescription(enc) );
}
}
void IntlTestCase::Domain()
{
// _() searches all domains by default:
- WX_ASSERT_STR_EQUAL( "&Ouvrir un fichier", _("&Open bogus file") );
+ CPPUNIT_ASSERT_EQUAL( "&Ouvrir un fichier", _("&Open bogus file") );
// search in our domain only:
- WX_ASSERT_STR_EQUAL( "&Ouvrir un fichier", wxGetTranslation("&Open bogus file", "internat") );
+ CPPUNIT_ASSERT_EQUAL( "&Ouvrir un fichier", wxGetTranslation("&Open bogus file", "internat") );
// search in a domain that doesn't have this string:
- WX_ASSERT_STR_EQUAL( "&Open bogus file", wxGetTranslation("&Open bogus file", "BogusDomain") );
+ CPPUNIT_ASSERT_EQUAL( "&Open bogus file", wxGetTranslation("&Open bogus file", "BogusDomain") );
}
void IntlTestCase::Headers()
{
- WX_ASSERT_STR_EQUAL( "wxWindows 2.0 i18n sample", m_locale->GetHeaderValue("Project-Id-Version") );
- WX_ASSERT_STR_EQUAL( "1999-01-13 18:19+0100", m_locale->GetHeaderValue("POT-Creation-Date") );
- WX_ASSERT_STR_EQUAL( "YEAR-MO-DA HO:MI+ZONE", m_locale->GetHeaderValue("PO-Revision-Date") );
- WX_ASSERT_STR_EQUAL( "Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr>", m_locale->GetHeaderValue("Last-Translator") );
- WX_ASSERT_STR_EQUAL( "1.0", m_locale->GetHeaderValue("MIME-Version") );
- WX_ASSERT_STR_EQUAL( "text/plain; charset=iso-8859-1", m_locale->GetHeaderValue("Content-Type") );
- WX_ASSERT_STR_EQUAL( "8bit", m_locale->GetHeaderValue("Content-Transfer-Encoding") );
+ CPPUNIT_ASSERT_EQUAL( "wxWindows 2.0 i18n sample", m_locale->GetHeaderValue("Project-Id-Version") );
+ CPPUNIT_ASSERT_EQUAL( "1999-01-13 18:19+0100", m_locale->GetHeaderValue("POT-Creation-Date") );
+ CPPUNIT_ASSERT_EQUAL( "YEAR-MO-DA HO:MI+ZONE", m_locale->GetHeaderValue("PO-Revision-Date") );
+ CPPUNIT_ASSERT_EQUAL( "Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr>", m_locale->GetHeaderValue("Last-Translator") );
+ CPPUNIT_ASSERT_EQUAL( "1.0", m_locale->GetHeaderValue("MIME-Version") );
+ CPPUNIT_ASSERT_EQUAL( "text/plain; charset=iso-8859-1", m_locale->GetHeaderValue("Content-Type") );
+ CPPUNIT_ASSERT_EQUAL( "8bit", m_locale->GetHeaderValue("Content-Transfer-Encoding") );
// check that it fails with a bogus domain:
- WX_ASSERT_STR_EQUAL( "", m_locale->GetHeaderValue("POT-Creation-Date", "Bogus") );
+ CPPUNIT_ASSERT_EQUAL( "", m_locale->GetHeaderValue("POT-Creation-Date", "Bogus") );
// and that it fails for nonexisting header:
- WX_ASSERT_STR_EQUAL( "", m_locale->GetHeaderValue("X-Not-Here") );
+ CPPUNIT_ASSERT_EQUAL( "", m_locale->GetHeaderValue("X-Not-Here") );
}
#endif // wxUSE_INTL
{
wxON_BLOCK_EXIT_SET(s, "bye");
- WX_ASSERT_STR_EQUAL( "hi", s );
+ CPPUNIT_ASSERT_EQUAL( "hi", s );
}
- WX_ASSERT_STR_EQUAL( "bye", s );
+ CPPUNIT_ASSERT_EQUAL( "bye", s );
ScopeGuardTestCase *p = this;
{
void DoTest(Stream& s)
{
s.PutC('x');
- WX_ASSERT_SIZET_EQUAL( 1, s.LastWrite() );
+ CPPUNIT_ASSERT_EQUAL( 1, s.LastWrite() );
s.SeekI(0);
CPPUNIT_ASSERT_EQUAL( int('x'), s.GetC() );
s7(s3.begin(), s3.begin() + 8);
wxString s8(s1, 4, 8);
- WX_ASSERT_STR_EQUAL( _T("abcdefgh"), s1 );
+ CPPUNIT_ASSERT_EQUAL( _T("abcdefgh"), s1 );
CPPUNIT_ASSERT_EQUAL( s1, s2 );
- WX_ASSERT_STR_EQUAL( _T("aaaaaaaa"), s4 );
- WX_ASSERT_STR_EQUAL( _T("abcdefgh"), s5 );
+ CPPUNIT_ASSERT_EQUAL( _T("aaaaaaaa"), s4 );
+ CPPUNIT_ASSERT_EQUAL( _T("abcdefgh"), s5 );
CPPUNIT_ASSERT_EQUAL( s1, s6 );
CPPUNIT_ASSERT_EQUAL( s1, s7 );
- WX_ASSERT_STR_EQUAL( _T("efgh"), s8 );
+ CPPUNIT_ASSERT_EQUAL( _T("efgh"), s8 );
const char *pc = s1.c_str();
- WX_ASSERT_STR_EQUAL( "bcd", wxString(pc + 1, pc + 4) );
+ CPPUNIT_ASSERT_EQUAL( "bcd", wxString(pc + 1, pc + 4) );
const wchar_t *pw = s2.c_str();
- WX_ASSERT_STR_EQUAL( "a", wxString(pw, pw + 1) );
+ CPPUNIT_ASSERT_EQUAL( "a", wxString(pw, pw + 1) );
}
void StdStringTestCase::StdIterators()
s5.append(1, (unsigned char)'y');
s6.append(s1.begin() + 3, s1.end());
- WX_ASSERT_STR_EQUAL( _T("abcdef"), s1 );
- WX_ASSERT_STR_EQUAL( _T("abcdef"), s2 );
- WX_ASSERT_STR_EQUAL( _T("abcdef"), s3 );
- WX_ASSERT_STR_EQUAL( _T("abcabcdef"), s4 );
- WX_ASSERT_STR_EQUAL( _T("abcaaaxxy"), s5 );
- WX_ASSERT_STR_EQUAL( _T("abcdef"), s6 );
+ CPPUNIT_ASSERT_EQUAL( _T("abcdef"), s1 );
+ CPPUNIT_ASSERT_EQUAL( _T("abcdef"), s2 );
+ CPPUNIT_ASSERT_EQUAL( _T("abcdef"), s3 );
+ CPPUNIT_ASSERT_EQUAL( _T("abcabcdef"), s4 );
+ CPPUNIT_ASSERT_EQUAL( _T("abcaaaxxy"), s5 );
+ CPPUNIT_ASSERT_EQUAL( _T("abcdef"), s6 );
const char *pc = s1.c_str() + 2;
s7.append(pc, pc + 4);
- WX_ASSERT_STR_EQUAL( "cdef", s7 );
+ CPPUNIT_ASSERT_EQUAL( "cdef", s7 );
const wchar_t *pw = s2.c_str() + 2;
s8.append(pw, pw + 4);
- WX_ASSERT_STR_EQUAL( "cdef", s8 );
+ CPPUNIT_ASSERT_EQUAL( "cdef", s8 );
s7 = s8 = wxString(_T("null\0time"), 9);
s5.assign(3, _T('a'));
s6.assign(s1.begin() + 1, s1.end());
- WX_ASSERT_STR_EQUAL( _T("def"), s1 );
- WX_ASSERT_STR_EQUAL( _T("def"), s2 );
- WX_ASSERT_STR_EQUAL( _T("def"), s3 );
- WX_ASSERT_STR_EQUAL( _T("def"), s4 );
- WX_ASSERT_STR_EQUAL( _T("aaa"), s5 );
- WX_ASSERT_STR_EQUAL( _T("ef"), s6 );
+ CPPUNIT_ASSERT_EQUAL( _T("def"), s1 );
+ CPPUNIT_ASSERT_EQUAL( _T("def"), s2 );
+ CPPUNIT_ASSERT_EQUAL( _T("def"), s3 );
+ CPPUNIT_ASSERT_EQUAL( _T("def"), s4 );
+ CPPUNIT_ASSERT_EQUAL( _T("aaa"), s5 );
+ CPPUNIT_ASSERT_EQUAL( _T("ef"), s6 );
const char *pc = s1.c_str();
s7.assign(pc, pc + 2);
- WX_ASSERT_STR_EQUAL( "de", s7 );
+ CPPUNIT_ASSERT_EQUAL( "de", s7 );
const wchar_t *pw = s1.c_str();
s8.assign(pw + 2, pw + 3);
- WX_ASSERT_STR_EQUAL( "f", s8 );
+ CPPUNIT_ASSERT_EQUAL( "f", s8 );
s1.assign(s1, 1, 1);
- WX_ASSERT_STR_EQUAL("e", s1);
+ CPPUNIT_ASSERT_EQUAL("e", s1);
}
void StdStringTestCase::StdCompare()
wxString::iterator it2 = s4.erase(s4.begin() + 4, s4.begin() + 6);
wxString::iterator it3 = s7.erase(s7.begin() + 4, s7.begin() + 8);
- WX_ASSERT_STR_EQUAL( _T("acdefgh"), s1 );
- WX_ASSERT_STR_EQUAL( _T("abcd"), s2 );
- WX_ASSERT_STR_EQUAL( _T("ac"), s3 );
- WX_ASSERT_STR_EQUAL( _T("abcdghi"), s4 );
- WX_ASSERT_STR_EQUAL( _T("zabc"), s7 );
+ CPPUNIT_ASSERT_EQUAL( _T("acdefgh"), s1 );
+ CPPUNIT_ASSERT_EQUAL( _T("abcd"), s2 );
+ CPPUNIT_ASSERT_EQUAL( _T("ac"), s3 );
+ CPPUNIT_ASSERT_EQUAL( _T("abcdghi"), s4 );
+ CPPUNIT_ASSERT_EQUAL( _T("zabc"), s7 );
CPPUNIT_ASSERT( *it == _T('c') );
CPPUNIT_ASSERT( *it2 == _T('g') );
CPPUNIT_ASSERT( it3 == s7.end() );
s7.insert(s7.begin(), s9.begin(), s9.end() - 1);
s8.insert(s8.begin(), 2, _T('c'));
- WX_ASSERT_STR_EQUAL( _T("accaaa") , s1 );
- WX_ASSERT_STR_EQUAL( _T("aacdeaa") , s2 );
- WX_ASSERT_STR_EQUAL( _T("aacdefgaa"), s3 );
- WX_ASSERT_STR_EQUAL( _T("aafgaa") , s4 );
- WX_ASSERT_STR_EQUAL( _T("accaaa") , s5 );
- WX_ASSERT_STR_EQUAL( _T("aaaXa") , s6 );
- WX_ASSERT_STR_EQUAL( _T("cdefaaaa") , s7 );
- WX_ASSERT_STR_EQUAL( _T("ccaaaa") , s8 );
+ CPPUNIT_ASSERT_EQUAL( _T("accaaa") , s1 );
+ CPPUNIT_ASSERT_EQUAL( _T("aacdeaa") , s2 );
+ CPPUNIT_ASSERT_EQUAL( _T("aacdefgaa"), s3 );
+ CPPUNIT_ASSERT_EQUAL( _T("aafgaa") , s4 );
+ CPPUNIT_ASSERT_EQUAL( _T("accaaa") , s5 );
+ CPPUNIT_ASSERT_EQUAL( _T("aaaXa") , s6 );
+ CPPUNIT_ASSERT_EQUAL( _T("cdefaaaa") , s7 );
+ CPPUNIT_ASSERT_EQUAL( _T("ccaaaa") , s8 );
s1 = s2 = s3 = _T("aaaa");
s1.insert(0, _T("ccc"), 2);
s2.insert(4, _T("ccc"), 2);
- WX_ASSERT_STR_EQUAL( _T("ccaaaa"), s1 );
- WX_ASSERT_STR_EQUAL( _T("aaaacc"), s2 );
+ CPPUNIT_ASSERT_EQUAL( _T("ccaaaa"), s1 );
+ CPPUNIT_ASSERT_EQUAL( _T("aaaacc"), s2 );
}
void StdStringTestCase::StdReplace()
s6.replace(0, 123, s9, 0, 123);
s7.replace(2, 7, s9);
- WX_ASSERT_STR_EQUAL( _T("QWErtyuIopopop"), s1 );
- WX_ASSERT_STR_EQUAL( _T("QWERTYUIOPWWWW"), s2 );
- WX_ASSERT_STR_EQUAL( _T("QwertyUIOP") , s3 );
- WX_ASSERT_STR_EQUAL( _T("QwertYUIOP") , s4 );
- WX_ASSERT_STR_EQUAL( _T("QertyRTYUIOP") , s5 );
+ CPPUNIT_ASSERT_EQUAL( _T("QWErtyuIopopop"), s1 );
+ CPPUNIT_ASSERT_EQUAL( _T("QWERTYUIOPWWWW"), s2 );
+ CPPUNIT_ASSERT_EQUAL( _T("QwertyUIOP") , s3 );
+ CPPUNIT_ASSERT_EQUAL( _T("QwertYUIOP") , s4 );
+ CPPUNIT_ASSERT_EQUAL( _T("QertyRTYUIOP") , s5 );
CPPUNIT_ASSERT_EQUAL( s9, s6 );
- WX_ASSERT_STR_EQUAL( _T("QWwertyP"), s7 );
+ CPPUNIT_ASSERT_EQUAL( _T("QWwertyP"), s7 );
}
void StdStringTestCase::StdRFind()
s3.resize( 14, _T(' ') );
s4.resize( 14, _T('W') );
- WX_ASSERT_STR_EQUAL( _T("abcABCdefDEF"), s1 );
- WX_ASSERT_STR_EQUAL( _T("abcABCdefD"), s2 );
- WX_ASSERT_STR_EQUAL( _T("abcABCdefDEF "), s3 );
- WX_ASSERT_STR_EQUAL( _T("abcABCdefDEFWW"), s4 );
+ CPPUNIT_ASSERT_EQUAL( _T("abcABCdefDEF"), s1 );
+ CPPUNIT_ASSERT_EQUAL( _T("abcABCdefD"), s2 );
+ CPPUNIT_ASSERT_EQUAL( _T("abcABCdefDEF "), s3 );
+ CPPUNIT_ASSERT_EQUAL( _T("abcABCdefDEFWW"), s4 );
wxString s =
wxString::FromUTF8("\xd0\x9f\xd1\x80\xd0\xb8\xd0\xb2\xd0\xb5\xd1\x82");
s.resize(3);
- WX_ASSERT_STR_EQUAL("\xd0\x9f\xd1\x80\xd0\xb8", s);
+ CPPUNIT_ASSERT_EQUAL("\xd0\x9f\xd1\x80\xd0\xb8", s);
}
void StdStringTestCase::StdRiter()
wxStdWideString strStdWide(L"std::wstring value");
wxString s1(strStd);
- WX_ASSERT_STR_EQUAL( "std::string value", s1 );
+ CPPUNIT_ASSERT_EQUAL( "std::string value", s1 );
wxString s2(strStdWide);
- WX_ASSERT_STR_EQUAL( "std::wstring value", s2 );
+ CPPUNIT_ASSERT_EQUAL( "std::wstring value", s2 );
wxString s3;
s3 = strStd;
- WX_ASSERT_STR_EQUAL( "std::string value", s3 );
+ CPPUNIT_ASSERT_EQUAL( "std::string value", s3 );
s3 = strStdWide;
- WX_ASSERT_STR_EQUAL( "std::wstring value", s3 );
+ CPPUNIT_ASSERT_EQUAL( "std::wstring value", s3 );
wxString s4("hello");
// because it conflicts with conversion to const char*/wchar_t*:
#if wxUSE_STL
std::string s5 = s4;
- WX_ASSERT_STR_EQUAL( "hello", s5 );
+ CPPUNIT_ASSERT_EQUAL( "hello", s5 );
wxStdWideString s6 = s4;
- WX_ASSERT_STR_EQUAL( "hello", s6 );
+ CPPUNIT_ASSERT_EQUAL( "hello", s6 );
#endif
std::string s7(s4);
void StringTestCase::Constructors()
{
- WX_ASSERT_STR_EQUAL( "", wxString('Z', 0) );
- WX_ASSERT_STR_EQUAL( "Z", wxString('Z') );
- WX_ASSERT_STR_EQUAL( "ZZZZ", wxString('Z', 4) );
- WX_ASSERT_STR_EQUAL( "Hell", wxString("Hello", 4) );
- WX_ASSERT_STR_EQUAL( "Hello", wxString("Hello", 5) );
+ CPPUNIT_ASSERT_EQUAL( "", wxString('Z', 0) );
+ CPPUNIT_ASSERT_EQUAL( "Z", wxString('Z') );
+ CPPUNIT_ASSERT_EQUAL( "ZZZZ", wxString('Z', 4) );
+ CPPUNIT_ASSERT_EQUAL( "Hell", wxString("Hello", 4) );
+ CPPUNIT_ASSERT_EQUAL( "Hello", wxString("Hello", 5) );
#if wxUSE_UNICODE
- WX_ASSERT_STR_EQUAL( L"", wxString(L'Z', 0) );
- WX_ASSERT_STR_EQUAL( L"Z", wxString(L'Z') );
- WX_ASSERT_STR_EQUAL( L"ZZZZ", wxString(L'Z', 4) );
- WX_ASSERT_STR_EQUAL( L"Hell", wxString(L"Hello", 4) );
- WX_ASSERT_STR_EQUAL( L"Hello", wxString(L"Hello", 5) );
+ CPPUNIT_ASSERT_EQUAL( L"", wxString(L'Z', 0) );
+ CPPUNIT_ASSERT_EQUAL( L"Z", wxString(L'Z') );
+ CPPUNIT_ASSERT_EQUAL( L"ZZZZ", wxString(L'Z', 4) );
+ CPPUNIT_ASSERT_EQUAL( L"Hell", wxString(L"Hello", 4) );
+ CPPUNIT_ASSERT_EQUAL( L"Hello", wxString(L"Hello", 5) );
#endif // wxUSE_UNICODE
static const char *s = "?really!";
const char *start = wxStrchr(s, 'r');
const char *end = wxStrchr(s, '!');
- WX_ASSERT_STR_EQUAL( "really", wxString(start, end) );
+ CPPUNIT_ASSERT_EQUAL( "really", wxString(start, end) );
// test if creating string from NULL C pointer works:
- WX_ASSERT_STR_EQUAL( "", wxString((const char *)NULL) );
+ CPPUNIT_ASSERT_EQUAL( "", wxString((const char *)NULL) );
}
void StringTestCase::StaticConstructors()
{
- WX_ASSERT_STR_EQUAL( "", wxString::FromAscii("") );
- WX_ASSERT_STR_EQUAL( "", wxString::FromAscii("Hello", 0) );
- WX_ASSERT_STR_EQUAL( "Hell", wxString::FromAscii("Hello", 4) );
- WX_ASSERT_STR_EQUAL( "Hello", wxString::FromAscii("Hello", 5) );
- WX_ASSERT_STR_EQUAL( "Hello", wxString::FromAscii("Hello") );
+ CPPUNIT_ASSERT_EQUAL( "", wxString::FromAscii("") );
+ CPPUNIT_ASSERT_EQUAL( "", wxString::FromAscii("Hello", 0) );
+ CPPUNIT_ASSERT_EQUAL( "Hell", wxString::FromAscii("Hello", 4) );
+ CPPUNIT_ASSERT_EQUAL( "Hello", wxString::FromAscii("Hello", 5) );
+ CPPUNIT_ASSERT_EQUAL( "Hello", wxString::FromAscii("Hello") );
// FIXME: this doesn't work currently but should!
- //WX_ASSERT_SIZET_EQUAL( 1, wxString::FromAscii("", 1).length() );
+ //CPPUNIT_ASSERT_EQUAL( 1, wxString::FromAscii("", 1).length() );
- WX_ASSERT_STR_EQUAL( "", wxString::FromUTF8("") );
- WX_ASSERT_STR_EQUAL( "", wxString::FromUTF8("Hello", 0) );
- WX_ASSERT_STR_EQUAL( "Hell", wxString::FromUTF8("Hello", 4) );
- WX_ASSERT_STR_EQUAL( "Hello", wxString::FromUTF8("Hello", 5) );
- WX_ASSERT_STR_EQUAL( "Hello", wxString::FromUTF8("Hello") );
+ CPPUNIT_ASSERT_EQUAL( "", wxString::FromUTF8("") );
+ CPPUNIT_ASSERT_EQUAL( "", wxString::FromUTF8("Hello", 0) );
+ CPPUNIT_ASSERT_EQUAL( "Hell", wxString::FromUTF8("Hello", 4) );
+ CPPUNIT_ASSERT_EQUAL( "Hello", wxString::FromUTF8("Hello", 5) );
+ CPPUNIT_ASSERT_EQUAL( "Hello", wxString::FromUTF8("Hello") );
- //WX_ASSERT_SIZET_EQUAL( 1, wxString::FromUTF8("", 1).length() );
+ //CPPUNIT_ASSERT_EQUAL( 1, wxString::FromUTF8("", 1).length() );
}
void StringTestCase::Extraction()
#define TEST_STARTS_WITH(prefix, correct_rest, result) \
CPPUNIT_ASSERT_EQUAL(result, s.StartsWith(prefix, &rest)); \
if ( result ) \
- WX_ASSERT_STR_EQUAL(correct_rest, rest)
+ CPPUNIT_ASSERT_EQUAL(correct_rest, rest)
TEST_STARTS_WITH( _T("Hello"), _T(", world!"), true );
TEST_STARTS_WITH( _T("Hello, "), _T("world!"), true );
rest = "Hello world";
CPPUNIT_ASSERT( rest.StartsWith("Hello ", &rest) );
- WX_ASSERT_STR_EQUAL("world", rest);
+ CPPUNIT_ASSERT_EQUAL("world", rest);
#define TEST_ENDS_WITH(suffix, correct_rest, result) \
CPPUNIT_ASSERT_EQUAL(result, s.EndsWith(suffix, &rest)); \
if ( result ) \
- WX_ASSERT_STR_EQUAL(correct_rest, rest)
+ CPPUNIT_ASSERT_EQUAL(correct_rest, rest)
TEST_ENDS_WITH( _T(""), _T("Hello, world!"), true );
TEST_ENDS_WITH( _T("!"), _T("Hello, world"), true );
{ \
wxString s = original; \
s.replace( pos , len , replacement ); \
- WX_ASSERT_STR_EQUAL( result, s ); \
+ CPPUNIT_ASSERT_EQUAL( result, s ); \
}
TEST_REPLACE( _T("012-AWORD-XYZ"), 4, 5, _T("BWORD"), _T("012-BWORD-XYZ") );
TEST_REPLACE( _T("foobar"), 3, 0, _T("-"), _T("foo-bar") );
TEST_REPLACE( _T("barfoo"), 0, 6, _T("foobar"), _T("foobar") );
-
+
#define TEST_NULLCHARREPLACE( o , olen, pos , len , replacement , r, rlen ) \
{ \
wxString s(o,olen); \
s.replace( pos , len , replacement ); \
CPPUNIT_ASSERT( s == wxString(r,rlen) ); \
}
-
- TEST_NULLCHARREPLACE( _T("null\0char"), 9, 5, 1, _T("d"),
- _T("null\0dhar"), 9 );
+
+ TEST_NULLCHARREPLACE( _T("null\0char"), 9, 5, 1, _T("d"),
+ _T("null\0dhar"), 9 );
#define TEST_WXREPLACE( o , olen, olds, news, all, r, rlen ) \
{ \
s.Replace( olds, news, all ); \
CPPUNIT_ASSERT( s == wxString(r,rlen) ); \
}
-
+
TEST_WXREPLACE( _T("null\0char"), 9, _T("c"), _T("de"), true,
- _T("null\0dehar"), 10 );
+ _T("null\0dehar"), 10 );
TEST_WXREPLACE( _T("null\0dehar"), 10, _T("de"), _T("c"), true,
- _T("null\0char"), 9 );
+ _T("null\0char"), 9 );
#undef TEST_WXREPLACE
#undef TEST_NULLCHARREPLACE
wxString s;
wxStrcpy(wxStringBuffer(s, 10), _T("foo"));
- WX_ASSERT_SIZET_EQUAL(3, s.length());
+ CPPUNIT_ASSERT_EQUAL(3, s.length());
CPPUNIT_ASSERT(_T('f') == s[0u]);
CPPUNIT_ASSERT(_T('o') == s[1]);
CPPUNIT_ASSERT(_T('o') == s[2]);
buf.SetLength(4);
}
- WX_ASSERT_SIZET_EQUAL(4, s.length());
+ CPPUNIT_ASSERT_EQUAL(4, s.length());
CPPUNIT_ASSERT(_T('b') == s[0u]);
CPPUNIT_ASSERT(_T('a') == s[1]);
CPPUNIT_ASSERT(_T('r') == s[2]);
#if wxUSE_UNICODE
const wchar_t wchar[] = {0x44,0xE9,0x6A,0xE0,0};
- WX_ASSERT_STR_EQUAL( wchar, s1 );
+ CPPUNIT_ASSERT_EQUAL( wchar, s1 );
wxString s2(wchar);
- WX_ASSERT_STR_EQUAL( wchar, s2 );
- WX_ASSERT_STR_EQUAL( utf8, s2 );
+ CPPUNIT_ASSERT_EQUAL( wchar, s2 );
+ CPPUNIT_ASSERT_EQUAL( utf8, s2 );
#else
- WX_ASSERT_STR_EQUAL( utf8, s1 );
+ CPPUNIT_ASSERT_EQUAL( utf8, s1 );
#endif
wxString sub(utf8sub, wxConvUTF8); // "Dej" substring
// test using Unicode strings together with char* strings (this must work
// in ANSI mode as well, of course):
wxString s5("ascii");
- WX_ASSERT_STR_EQUAL( "ascii", s5 );
+ CPPUNIT_ASSERT_EQUAL( "ascii", s5 );
s5 += " value";
CPPUNIT_ASSERT( strcmp(s5.mb_str(), "ascii value") == 0 );
- WX_ASSERT_STR_EQUAL( "ascii value", s5 );
+ CPPUNIT_ASSERT_EQUAL( "ascii value", s5 );
CPPUNIT_ASSERT( s5 != "SomethingElse" );
}
// test using wchar_t:
s.Printf("char=%c", L'c');
- WX_ASSERT_STR_EQUAL( "char=c", s );
+ CPPUNIT_ASSERT_EQUAL( "char=c", s );
// test wxUniCharRef:
s.Printf("string[1] is %c", foo[1]);
- WX_ASSERT_STR_EQUAL( "string[1] is o", s );
+ CPPUNIT_ASSERT_EQUAL( "string[1] is o", s );
// test char
char c = 'z';
s.Printf("%c to %c", 'a', c);
- WX_ASSERT_STR_EQUAL( "a to z", s );
+ CPPUNIT_ASSERT_EQUAL( "a to z", s );
// test char used as integer:
#ifdef _MSC_VER
#pragma warning(default:4309)
#endif
s.Printf("value is %i (int)", c);
- WX_ASSERT_STR_EQUAL( wxString("value is -16 (int)"), s );
+ CPPUNIT_ASSERT_EQUAL( wxString("value is -16 (int)"), s );
unsigned char u = 240;
s.Printf("value is %i (int)", u);
- WX_ASSERT_STR_EQUAL( wxString("value is 240 (int)"), s );
+ CPPUNIT_ASSERT_EQUAL( "value is 240 (int)", s );
}
#if wxUSE_STD_STRING
std::string wc("widechar");
s.Printf("string %s(%i).", mb, 1);
- CPPUNIT_ASSERT( s == "string multi-byte(1)." );
+ CPPUNIT_ASSERT_EQUAL( "string multi-byte(1).", s );
s.Printf("string %s(%i).", wc, 2);
- CPPUNIT_ASSERT( s == "string widechar(2)." );
+ CPPUNIT_ASSERT_EQUAL( "string widechar(2).", s );
}
#endif // wxUSE_STD_STRING
v.push_back(CountedObject(3));
v.erase(v.begin());
- WX_ASSERT_SIZET_EQUAL( 2, v.size() );
+ CPPUNIT_ASSERT_EQUAL( 2, v.size() );
CPPUNIT_ASSERT_EQUAL( 2, CountedObject::GetCount() );
v.clear();
break;
CPPUNIT_ASSERT( child );
- WX_ASSERT_STR_EQUAL( childName, child->GetName() );
+ CPPUNIT_ASSERT_EQUAL( childName, child->GetName() );
CPPUNIT_ASSERT( child->GetChildren() == NULL );
CPPUNIT_ASSERT( child->GetParent() == n );