Replacements for some wcsxxx funcs for systems without them like osx 10.2.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@35159 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -201,6 +201,28 @@ void MBConvTestCase::UTF8Octal(const char *charSequence,
|
|||||||
UTF8(charSequence, NULL, wxMBConvUTF8::MAP_INVALID_UTF8_TO_OCTAL);
|
UTF8(charSequence, NULL, wxMBConvUTF8::MAP_INVALID_UTF8_TO_OCTAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// in case wcscpy is missing
|
||||||
|
//
|
||||||
|
static wchar_t *wx_wcscpy(wchar_t *dest, const wchar_t *src)
|
||||||
|
{
|
||||||
|
wchar_t *d = dest;
|
||||||
|
while ((*d++ = *src++) != 0)
|
||||||
|
;
|
||||||
|
return dest;
|
||||||
|
}
|
||||||
|
|
||||||
|
// in case wcscat is missing
|
||||||
|
//
|
||||||
|
static wchar_t *wx_wcscat(wchar_t *dest, const wchar_t *src)
|
||||||
|
{
|
||||||
|
wchar_t *d = dest;
|
||||||
|
while (*d)
|
||||||
|
d++;
|
||||||
|
while ((*d++ = *src++) != 0)
|
||||||
|
;
|
||||||
|
return dest;
|
||||||
|
}
|
||||||
|
|
||||||
// include the option in the error messages so it's possible to see which
|
// include the option in the error messages so it's possible to see which
|
||||||
// test failed
|
// test failed
|
||||||
#define UTF8ASSERT(expr) CPPUNIT_ASSERT_MESSAGE(#expr + errmsg, expr)
|
#define UTF8ASSERT(expr) CPPUNIT_ASSERT_MESSAGE(#expr + errmsg, expr)
|
||||||
@@ -240,11 +262,11 @@ void MBConvTestCase::UTF8(const char *charSequence,
|
|||||||
wxASSERT(result < BUFSIZE);
|
wxASSERT(result < BUFSIZE);
|
||||||
|
|
||||||
wchar_t expected[BUFSIZE];
|
wchar_t expected[BUFSIZE];
|
||||||
wcscpy(expected, wideSequence);
|
wx_wcscpy(expected, wideSequence);
|
||||||
wcscat(expected, L"ABC");
|
wx_wcscat(expected, L"ABC");
|
||||||
wcscat(expected, wideSequence);
|
wx_wcscat(expected, wideSequence);
|
||||||
wcscat(expected, L"XYZ");
|
wx_wcscat(expected, L"XYZ");
|
||||||
wcscat(expected, wideSequence);
|
wx_wcscat(expected, wideSequence);
|
||||||
|
|
||||||
UTF8ASSERT(wcscmp(widechars, expected) == 0);
|
UTF8ASSERT(wcscmp(widechars, expected) == 0);
|
||||||
UTF8ASSERT(wcslen(widechars) == result);
|
UTF8ASSERT(wcslen(widechars) == result);
|
||||||
|
@@ -222,6 +222,21 @@ void StringTestCase::Conversion()
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// in case wcscmp is missing
|
||||||
|
//
|
||||||
|
static int wx_wcscmp(const wchar_t *s1, const wchar_t *s2)
|
||||||
|
{
|
||||||
|
for (;;) {
|
||||||
|
if (*s1 != *s2)
|
||||||
|
return *s1 - *s2;
|
||||||
|
if (*s1 == 0)
|
||||||
|
break;
|
||||||
|
s1++;
|
||||||
|
s2++;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
StringTestCase::DoTestConversion(const char *s,
|
StringTestCase::DoTestConversion(const char *s,
|
||||||
const wchar_t *ws,
|
const wchar_t *ws,
|
||||||
@@ -240,7 +255,7 @@ StringTestCase::DoTestConversion(const char *s,
|
|||||||
wxWCharBuffer wbuf(wxString(s).wc_str(conv));
|
wxWCharBuffer wbuf(wxString(s).wc_str(conv));
|
||||||
|
|
||||||
if ( ws )
|
if ( ws )
|
||||||
CPPUNIT_ASSERT( wcscmp(wbuf, ws) == 0 );
|
CPPUNIT_ASSERT( wx_wcscmp(wbuf, ws) == 0 );
|
||||||
else
|
else
|
||||||
CPPUNIT_ASSERT( !*wbuf );
|
CPPUNIT_ASSERT( !*wbuf );
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user