X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/77fa3d8243a5118b3edcccfeb18279b7e04aa51d..fda71b397a368f4b36a73a387c58ade2c928d9db:/include/wx/cppunit.h?ds=sidebyside diff --git a/include/wx/cppunit.h b/include/wx/cppunit.h index 3b4281cfa1..503ed3e8e0 100644 --- a/include/wx/cppunit.h +++ b/include/wx/cppunit.h @@ -55,6 +55,8 @@ #include #include "wx/afterstd.h" +#include "wx/string.h" + /////////////////////////////////////////////////////////////////////////////// // Set of helpful test macros. @@ -81,11 +83,40 @@ #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); +} -// 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 @@ -104,10 +135,6 @@ } \ } -// 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) \