]> git.saurik.com Git - wxWidgets.git/commitdiff
added small UTF 8 conversion test case
authorVadim Zeitlin <vadim@wxwidgets.org>
Mon, 31 Jan 2005 00:31:47 +0000 (00:31 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Mon, 31 Jan 2005 00:31:47 +0000 (00:31 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@31665 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

tests/strings/strings.cpp

index 858bcab7d4ad991faeffb48128ca592cca947c9c..bc1c4c00bbc52d9ba82a3111365a22c08424a6c3 100644 (file)
@@ -42,7 +42,8 @@ private:
         CPPUNIT_TEST( ConstructorsWithConversion );
         CPPUNIT_TEST( Conversion );
         CPPUNIT_TEST( ConversionUTF7 );
-#endif
+        CPPUNIT_TEST( ConversionUTF8 );
+#endif // wxUSE_WCHAR_T
         CPPUNIT_TEST( Extraction );
         CPPUNIT_TEST( Find );
         CPPUNIT_TEST( Tokenizer );
@@ -62,7 +63,8 @@ private:
     void ConstructorsWithConversion();
     void Conversion();
     void ConversionUTF7();
-#endif
+    void ConversionUTF8();
+#endif // wxUSE_WCHAR_T
     void Extraction();
     void Find();
     void SingleTokenizerTest( wxChar *str, wxChar *delims, size_t count , wxStringTokenizerMode mode );
@@ -248,6 +250,24 @@ void StringTestCase::ConversionUTF7()
 #endif // wxUSE_UNICODE
 }
 
+void StringTestCase::ConversionUTF8()
+{
+    const wchar_t wcs[] = { 0x00A3, 0x00A3, 0x00A3, 0x00A3, 0 }; // pound signs
+    const char *utf8 = "\xc2\xa3\xc2\xa3\xc2\xa3\xc2\xa3";
+
+    wxCSConv conv(_T("utf-8"));
+
+#if wxUSE_UNICODE
+    wxCharBuffer buf(wxString(wcs).mb_str(conv));
+
+    CPPUNIT_ASSERT( strcmp(buf, utf8) == 0 );
+#else // !wxUSE_UNICODE
+    wxWCharBuffer wbuf(wxString(utf8).wc_str(conv));
+
+    CPPUNIT_ASSERT( wcscmp(wbuf, wcs) == 0 );
+#endif // wxUSE_UNICODE/!wxUSE_UNICODE
+}
+
 #endif // wxUSE_WCHAR_T