X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/8f1158912fc28ed542d50e7205a3f961b8c764b7..ec02a2f7de3d6f4e11c4dd72bf69c33fcc49ba84:/tests/mbconv/mbconvtest.cpp diff --git a/tests/mbconv/mbconvtest.cpp b/tests/mbconv/mbconvtest.cpp index 632ee3c8ba..f7bebaad1a 100644 --- a/tests/mbconv/mbconvtest.cpp +++ b/tests/mbconv/mbconvtest.cpp @@ -212,7 +212,7 @@ private: CPPUNIT_TEST_SUITE_REGISTRATION( MBConvTestCase ); // also include in it's own registry so that these tests can be run alone -CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( MBConvTestCase, "MBConvTestCase" ); +CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( MBConvTestCase, "MBConv" ); void MBConvTestCase::WC2CP1250() { @@ -971,14 +971,16 @@ void MBConvTestCase::TestEncoder( // make sure the characters generated are correct CPPUNIT_ASSERT( 0 == memcmp( outputBuffer, multiBuffer, multiBytes ) ); + size_t i; + // the output buffer should be null terminated - for ( size_t i = multiBytes; i < multiBytes + sizeofNull; i++ ) + for ( i = multiBytes; i < multiBytes + sizeofNull; i++ ) { CPPUNIT_ASSERT( ((unsigned char*)outputBuffer.data())[i] == 0 ); } // make sure the rest of the output buffer is untouched - for ( size_t i = multiBytes + sizeofNull; i < outputBufferSize; i++ ) + for ( i = multiBytes + sizeofNull; i < outputBufferSize; i++ ) { CPPUNIT_ASSERT( ((unsigned char*)outputBuffer.data())[i] == UNINITIALIZED ); } @@ -1106,6 +1108,28 @@ static wchar_t *wx_wcscat(wchar_t *dest, const wchar_t *src) return dest; } +// in case wcscmp is missing +// +static int wx_wcscmp(const wchar_t *s1, const wchar_t *s2) +{ + while (*s1 == *s2 && *s1 != 0) + { + s1++; + s2++; + } + return *s1 - *s2; +} + +// in case wcslen is missing +// +static size_t wx_wcslen(const wchar_t *s) +{ + const wchar_t *t = s; + while (*t != 0) + t++; + return t - s; +} + // include the option in the error messages so it's possible to see which // test failed #define UTF8ASSERT(expr) CPPUNIT_ASSERT_MESSAGE(#expr + errmsg, expr) @@ -1151,8 +1175,8 @@ void MBConvTestCase::UTF8(const char *charSequence, wx_wcscat(expected, L"XYZ"); wx_wcscat(expected, wideSequence); - UTF8ASSERT(wcscmp(widechars, expected) == 0); - UTF8ASSERT(wcslen(widechars) == result); + UTF8ASSERT(wx_wcscmp(widechars, expected) == 0); + UTF8ASSERT(wx_wcslen(widechars) == result); } else { // If 'wideSequence' is NULL, then the result is expected to be