overload wxStrpbrk() for more types and add tests for it
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@46450 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
parent
1757c449c4
commit
105260e89f
@ -630,22 +630,33 @@ inline const char *wxStrpbrk(const char *s, const char *accept)
|
||||
{ return wxCRT_StrpbrkA(s, accept); }
|
||||
inline const wchar_t *wxStrpbrk(const wchar_t *s, const wchar_t *accept)
|
||||
{ return wxCRT_StrpbrkW(s, accept); }
|
||||
inline const char *wxStrpbrk(const char *s, const wxCharBuffer& accept)
|
||||
{ return wxCRT_StrpbrkA(s, accept.data()); }
|
||||
inline const char *wxStrpbrk(const char *s, const wxString& accept)
|
||||
{ return wxCRT_StrpbrkA(s, accept.mb_str()); }
|
||||
inline const char *wxStrpbrk(const char *s, const wxCStrData& accept)
|
||||
{ return wxCRT_StrpbrkA(s, accept.AsCharBuf()); }
|
||||
inline const wchar_t *wxStrpbrk(const wchar_t *s, const wxWCharBuffer& accept)
|
||||
{ return wxCRT_StrpbrkW(s, accept.data()); }
|
||||
inline const wchar_t *wxStrpbrk(const wchar_t *s, const wxString& accept)
|
||||
{ return wxCRT_StrpbrkW(s, accept.wc_str()); }
|
||||
inline const wchar_t *wxStrpbrk(const wchar_t *s, const wxCStrData& accept)
|
||||
{ return wxCRT_StrpbrkW(s, accept.AsWCharBuf()); }
|
||||
inline const char *wxStrpbrk(const wxString& s, const wxString& accept)
|
||||
{ return wxCRT_StrpbrkA(s.c_str(), accept.mb_str()); }
|
||||
inline const char *wxStrpbrk(const wxString& s, const char *accept)
|
||||
{ return wxCRT_StrpbrkA(s.c_str(), accept); }
|
||||
inline const wchar_t *wxStrpbrk(const wxString& s, const wchar_t *accept)
|
||||
{ return wxCRT_StrpbrkW(s.wc_str(), accept); }
|
||||
inline const char *wxStrpbrk(const wxString& s, const wxCStrData& accept)
|
||||
{ return wxCRT_StrpbrkA(s.c_str(), accept.AsCharBuf()); }
|
||||
inline const char *wxStrpbrk(const wxCStrData& s, const wxString& accept)
|
||||
{ return wxCRT_StrpbrkA(s.AsChar(), accept.mb_str()); }
|
||||
inline const char *wxStrpbrk(const wxCStrData& s, const char *accept)
|
||||
{ return wxCRT_StrpbrkA(s.AsChar(), accept); }
|
||||
inline const wchar_t *wxStrpbrk(const wxCStrData& s, const wchar_t *accept)
|
||||
{ return wxCRT_StrpbrkW(s.AsWChar(), accept); }
|
||||
inline const char *wxStrpbrk(const wxCStrData& s, const wxCStrData& accept)
|
||||
{ return wxCRT_StrpbrkA(s.AsChar(), accept.AsCharBuf()); }
|
||||
template <typename S, typename T>
|
||||
inline const T *wxStrpbrk(const S& s, const wxCharTypeBuffer<T>& accept)
|
||||
{ return wxStrpbrk(s, accept.data()); }
|
||||
|
||||
|
||||
/* inlined non-const versions */
|
||||
|
@ -47,12 +47,14 @@ private:
|
||||
CPPUNIT_TEST( Strcmp );
|
||||
CPPUNIT_TEST( Strspn );
|
||||
CPPUNIT_TEST( Strcspn );
|
||||
CPPUNIT_TEST( Strpbrk );
|
||||
CPPUNIT_TEST_SUITE_END();
|
||||
|
||||
void SetGetEnv();
|
||||
void Strcmp();
|
||||
void Strspn();
|
||||
void Strcspn();
|
||||
void Strpbrk();
|
||||
|
||||
DECLARE_NO_COPY_CLASS(CrtTestCase)
|
||||
};
|
||||
@ -177,3 +179,33 @@ void CrtTestCase::Strcspn()
|
||||
CPPUNIT_ASSERT_EQUAL( strWX.length(), wxStrcspn(strWX, "xy") );
|
||||
}
|
||||
|
||||
void CrtTestCase::Strpbrk()
|
||||
{
|
||||
const wxString s(", ");
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL( ',', *wxStrpbrk(strMB, ", ") );
|
||||
CPPUNIT_ASSERT_EQUAL( L',', *wxStrpbrk(strWC, L", ") );
|
||||
CPPUNIT_ASSERT_EQUAL( ',', *wxStrpbrk(strWX, ", ") );
|
||||
CPPUNIT_ASSERT_EQUAL( L',', *wxStrpbrk(strWX, L", ") );
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL( ',', *wxStrpbrk(strMB, s) );
|
||||
CPPUNIT_ASSERT_EQUAL( L',', *wxStrpbrk(strWC, s) );
|
||||
CPPUNIT_ASSERT_EQUAL( ',', *wxStrpbrk(strWX, s) );
|
||||
CPPUNIT_ASSERT_EQUAL( ',', *wxStrpbrk(strWX.c_str(), s) );
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL( ',', *wxStrpbrk(strMB, s.c_str()) );
|
||||
CPPUNIT_ASSERT_EQUAL( L',', *wxStrpbrk(strWC, s.c_str()) );
|
||||
CPPUNIT_ASSERT_EQUAL( ',', *wxStrpbrk(strWX, s.c_str()) );
|
||||
CPPUNIT_ASSERT_EQUAL( ',', *wxStrpbrk(strWX.c_str(), s.c_str()) );
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL( ',', *wxStrpbrk(strMB, s.mb_str()) );
|
||||
CPPUNIT_ASSERT_EQUAL( L',', *wxStrpbrk(strWC, s.wc_str()) );
|
||||
CPPUNIT_ASSERT_EQUAL( ',', *wxStrpbrk(strWX, s.mb_str()) );
|
||||
CPPUNIT_ASSERT_EQUAL( L',', *wxStrpbrk(strWX, s.wc_str()) );
|
||||
CPPUNIT_ASSERT_EQUAL( ',', *wxStrpbrk(strWX.c_str(), s.mb_str()) );
|
||||
CPPUNIT_ASSERT_EQUAL( L',', *wxStrpbrk(strWX.c_str(), s.wc_str()) );
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL( (const char *)NULL, wxStrpbrk(strWX, "xyz") );
|
||||
CPPUNIT_ASSERT_EQUAL( (const wchar_t *)NULL, wxStrpbrk(strWX.c_str(), L"xyz") );
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user