added test for operator?: and wxCStrData
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@45096 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -53,6 +53,7 @@ private:
|
|||||||
#endif // wxLongLong_t
|
#endif // wxLongLong_t
|
||||||
CPPUNIT_TEST( ToDouble );
|
CPPUNIT_TEST( ToDouble );
|
||||||
CPPUNIT_TEST( WriteBuf );
|
CPPUNIT_TEST( WriteBuf );
|
||||||
|
CPPUNIT_TEST( CStrData );
|
||||||
CPPUNIT_TEST_SUITE_END();
|
CPPUNIT_TEST_SUITE_END();
|
||||||
|
|
||||||
void String();
|
void String();
|
||||||
@@ -76,6 +77,8 @@ private:
|
|||||||
#endif // wxLongLong_t
|
#endif // wxLongLong_t
|
||||||
void ToDouble();
|
void ToDouble();
|
||||||
void WriteBuf();
|
void WriteBuf();
|
||||||
|
void CStrData();
|
||||||
|
void DoCStrData(bool cond);
|
||||||
|
|
||||||
DECLARE_NO_COPY_CLASS(StringTestCase)
|
DECLARE_NO_COPY_CLASS(StringTestCase)
|
||||||
};
|
};
|
||||||
@@ -652,3 +655,39 @@ void StringTestCase::WriteBuf()
|
|||||||
CPPUNIT_ASSERT_EQUAL( 0, wxStrcmp(_T("barr"), s) );
|
CPPUNIT_ASSERT_EQUAL( 0, wxStrcmp(_T("barr"), s) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void StringTestCase::CStrData()
|
||||||
|
{
|
||||||
|
DoCStrData(true);
|
||||||
|
DoCStrData(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T> bool CheckStr(const wxString& expected, T s)
|
||||||
|
{
|
||||||
|
return expected == wxString(s);
|
||||||
|
}
|
||||||
|
|
||||||
|
void StringTestCase::DoCStrData(bool cond)
|
||||||
|
{
|
||||||
|
// test compilation of wxCStrData when used with operator?: (the asserts
|
||||||
|
// are not very important, we're testing if the code compiles at all):
|
||||||
|
|
||||||
|
wxString s("foo");
|
||||||
|
const char *mbStr = "foo";
|
||||||
|
const wchar_t *wcStr = L"foo";
|
||||||
|
|
||||||
|
// FIXME-UTF8: when wxCStrData can handle both conversions, this should
|
||||||
|
// be changed to always test all versions, both MB and WC
|
||||||
|
#if wxUSE_UNICODE
|
||||||
|
CPPUNIT_ASSERT( CheckStr(s, (cond ? s.c_str() : wcStr)) );
|
||||||
|
CPPUNIT_ASSERT( CheckStr(s, (cond ? s.c_str() : L"bar")) );
|
||||||
|
CPPUNIT_ASSERT( CheckStr(s, (cond ? wcStr : s.c_str())) );
|
||||||
|
CPPUNIT_ASSERT( CheckStr(s, (cond ? L"bar" : s.c_str())) );
|
||||||
|
#else
|
||||||
|
CPPUNIT_ASSERT( CheckStr(s, (cond ? s.c_str() : mbStr)) );
|
||||||
|
CPPUNIT_ASSERT( CheckStr(s, (cond ? s.c_str() : "foo")) );
|
||||||
|
CPPUNIT_ASSERT( CheckStr(s, (cond ? mbStr : s.c_str())) );
|
||||||
|
CPPUNIT_ASSERT( CheckStr(s, (cond ? "foo" : s.c_str())) );
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user