+
+void CrtTestCase::Strcspn()
+{
+ CPPUNIT_ASSERT_EQUAL( (size_t)0, wxStrcspn(strMB, strWX) );
+ CPPUNIT_ASSERT_EQUAL( (size_t)0, wxStrcspn(strWC, strMB) );
+ CPPUNIT_ASSERT_EQUAL( (size_t)0, wxStrcspn(strWX, strWC) );
+
+ CPPUNIT_ASSERT_EQUAL( (size_t)5, wxStrcspn(strMB, ", ") );
+ CPPUNIT_ASSERT_EQUAL( (size_t)5, wxStrcspn(strWC, ", ") );
+ CPPUNIT_ASSERT_EQUAL( (size_t)5, wxStrcspn(strWX, ", ") );
+
+ CPPUNIT_ASSERT_EQUAL( (size_t)0, wxStrcspn(strMB, "hel") );
+ CPPUNIT_ASSERT_EQUAL( (size_t)0, wxStrcspn(strWC, "hel") );
+ CPPUNIT_ASSERT_EQUAL( (size_t)0, wxStrcspn(strWX, "hel") );
+
+ CPPUNIT_ASSERT_EQUAL( strWX.length(), wxStrcspn(strMB, "xy") );
+ CPPUNIT_ASSERT_EQUAL( strWX.length(), wxStrcspn(strWC, "xy") );
+ 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( !wxStrpbrk(strWX, "xyz") );
+ CPPUNIT_ASSERT( !wxStrpbrk(strWX.c_str(), L"xyz") );
+}
+
+void CrtTestCase::Strnlen()
+{
+ // other misc tests for wxStrnlen(const char*, size_t)
+
+ CPPUNIT_ASSERT_EQUAL( (size_t)0, wxStrnlen("", 0) );
+ CPPUNIT_ASSERT_EQUAL( (size_t)0, wxStrnlen("", 8) );
+ CPPUNIT_ASSERT_EQUAL( (size_t)0, wxStrnlen("1234", 0) );
+ CPPUNIT_ASSERT_EQUAL( (size_t)2, wxStrnlen("1234", 2) );
+ CPPUNIT_ASSERT_EQUAL( (size_t)4, wxStrnlen("1234", 8) );
+ CPPUNIT_ASSERT_EQUAL( (size_t)7, wxStrnlen("1234567", 8) );
+ CPPUNIT_ASSERT_EQUAL( (size_t)8, wxStrnlen("12345678", 8) );
+ CPPUNIT_ASSERT_EQUAL( (size_t)8, wxStrnlen("123456789", 8) );
+ CPPUNIT_ASSERT_EQUAL( (size_t)9, wxStrnlen("123456789", 12) );
+
+ // other misc tests for wxStrnlen(const wchar_t*, size_t)
+
+ CPPUNIT_ASSERT_EQUAL( (size_t)0, wxStrnlen(L"", 0) );
+ CPPUNIT_ASSERT_EQUAL( (size_t)0, wxStrnlen(L"", 8) );
+ CPPUNIT_ASSERT_EQUAL( (size_t)0, wxStrnlen(L"1234", 0) );
+ CPPUNIT_ASSERT_EQUAL( (size_t)2, wxStrnlen(L"1234", 2) );
+ CPPUNIT_ASSERT_EQUAL( (size_t)4, wxStrnlen(L"1234", 8) );
+ CPPUNIT_ASSERT_EQUAL( (size_t)7, wxStrnlen(L"1234567", 8) );
+ CPPUNIT_ASSERT_EQUAL( (size_t)8, wxStrnlen(L"12345678", 8) );
+ CPPUNIT_ASSERT_EQUAL( (size_t)8, wxStrnlen(L"123456789", 8) );
+ CPPUNIT_ASSERT_EQUAL( (size_t)9, wxStrnlen(L"123456789", 12) );
+
+ // wxStrlen() is only for NULL-terminated strings:
+ CPPUNIT_ASSERT_EQUAL( (size_t)4, wxStrnlen("1234" "\0" "78", 12) );
+ CPPUNIT_ASSERT_EQUAL( (size_t)4, wxStrnlen(L"1234" L"\0" L"5678", 12) );
+}
+
+
+