diff --git a/tests/file/filefn.cpp b/tests/file/filefn.cpp index 4207545835..c347639d75 100644 --- a/tests/file/filefn.cpp +++ b/tests/file/filefn.cpp @@ -86,7 +86,9 @@ private: const wxString& destFilePath); wxString m_fileNameASCII; +#if wxUSE_UNICODE wxString m_fileNameNonASCII; +#endif // wxUSE_UNICODE wxString m_fileNameWork; wxDECLARE_NO_COPY_CLASS(FileFunctionsTestCase); @@ -110,10 +112,12 @@ void FileFunctionsTestCase::setUp() wxFileName fn1(wxFileName::GetTempDir(), wxT("wx_file_mask.txt")); m_fileNameASCII = fn1.GetFullPath(); +#if wxUSE_UNICODE // This file name is 'wx_file_mask.txt' in Russian. wxFileName fn2(wxFileName::GetTempDir(), wxT("wx_\u043C\u0430\u0441\u043A\u0430_\u0444\u0430\u0439\u043B\u0430.txt")); m_fileNameNonASCII = fn2.GetFullPath(); +#endif // wxUSE_UNICODE wxFileName fn3(wxFileName::GetTempDir(), wxT("wx_test_copy")); m_fileNameWork = fn3.GetFullPath(); @@ -126,10 +130,12 @@ void FileFunctionsTestCase::tearDown() { wxRemoveFile(m_fileNameASCII); } +#if wxUSE_UNICODE if ( wxFileExists(m_fileNameNonASCII) ) { wxRemoveFile(m_fileNameNonASCII); } +#endif // wxUSE_UNICODE if ( wxFileExists(m_fileNameWork) ) { wxRemoveFile(m_fileNameWork); @@ -176,8 +182,10 @@ void FileFunctionsTestCase::CreateFile() { // Create file name containing ASCII characters only. DoCreateFile(m_fileNameASCII); +#if wxUSE_UNICODE // Create file name containing non-ASCII characters. DoCreateFile(m_fileNameNonASCII); +#endif // wxUSE_UNICODE } void FileFunctionsTestCase::DoCreateFile(const wxString& filePath) @@ -199,8 +207,10 @@ void FileFunctionsTestCase::FileExists() // Check file name containing ASCII characters only. DoFileExists(m_fileNameASCII); +#if wxUSE_UNICODE // Check file name containing non-ASCII characters. DoFileExists(m_fileNameNonASCII); +#endif // wxUSE_UNICODE } void FileFunctionsTestCase::DoFileExists(const wxString& filePath) @@ -223,8 +233,10 @@ void FileFunctionsTestCase::FindFile() { // Find file name containing ASCII characters only. DoFindFile(m_fileNameASCII); +#if wxUSE_UNICODE // Find file name containing non-ASCII characters. DoFindFile(m_fileNameNonASCII); +#endif // wxUSE_UNICODE } void FileFunctionsTestCase::DoFindFile(const wxString& filePath) @@ -283,8 +295,10 @@ void FileFunctionsTestCase::RemoveFile() { // Create & remove file with name containing ASCII characters only. DoRemoveFile(m_fileNameASCII); +#if wxUSE_UNICODE // Create & remove file with name containing non-ASCII characters. DoRemoveFile(m_fileNameNonASCII); +#endif // wxUSE_UNICODE } void FileFunctionsTestCase::DoRemoveFile(const wxString& filePath) @@ -305,6 +319,7 @@ void FileFunctionsTestCase::RenameFile() { // Verify renaming file with/without overwriting // when new file already exist/don't exist. +#if wxUSE_UNICODE DoRenameFile(m_fileNameASCII, m_fileNameNonASCII, false, false); DoRenameFile(m_fileNameASCII, m_fileNameNonASCII, false, true); DoRenameFile(m_fileNameASCII, m_fileNameNonASCII, true, false); @@ -313,6 +328,7 @@ void FileFunctionsTestCase::RenameFile() DoRenameFile(m_fileNameNonASCII, m_fileNameASCII, false, true); DoRenameFile(m_fileNameNonASCII, m_fileNameASCII, true, false); DoRenameFile(m_fileNameNonASCII, m_fileNameASCII, true, true); +#endif // wxUSE_UNICODE } void @@ -378,8 +394,10 @@ FileFunctionsTestCase::DoRenameFile(const wxString& oldFilePath, void FileFunctionsTestCase::ConcatenateFiles() { +#if wxUSE_UNICODE DoConcatFile(m_fileNameASCII, m_fileNameNonASCII, m_fileNameWork); DoConcatFile(m_fileNameNonASCII, m_fileNameASCII, m_fileNameWork); +#endif // wxUSE_UNICODE } void FileFunctionsTestCase::DoConcatFile(const wxString& filePath1, @@ -525,21 +543,25 @@ void FileFunctionsTestCase::PathOnly() // Rmdir fails on them on Linux. See ticket #17644. void FileFunctionsTestCase::Mkdir() { +#if wxUSE_UNICODE wxString dirname = wxString::FromUTF8("__wxMkdir_test_dir_with_\xc3\xb6"); const std::string msg = wxString::Format("Dir: %s", dirname).ToStdString(); CPPUNIT_ASSERT_MESSAGE( msg, wxMkdir(dirname) ); CPPUNIT_ASSERT_MESSAGE( msg, wxDirExists(dirname) ); CPPUNIT_ASSERT_MESSAGE( msg, wxRmdir(dirname) ); +#endif // wxUSE_UNICODE } void FileFunctionsTestCase::Rmdir() { +#if wxUSE_UNICODE wxString dirname = wxString::FromUTF8("__wxRmdir_test_dir_with_\xc3\xb6"); const std::string msg = wxString::Format("Dir: %s", dirname).ToStdString(); CPPUNIT_ASSERT_MESSAGE( msg, wxMkdir(dirname) ); CPPUNIT_ASSERT_MESSAGE( msg, wxRmdir(dirname) ); CPPUNIT_ASSERT_MESSAGE( msg, !wxDirExists(dirname) ); +#endif // wxUSE_UNICODE } /* diff --git a/tests/streams/datastreamtest.cpp b/tests/streams/datastreamtest.cpp index a98c3af3ed..27bf25aa92 100644 --- a/tests/streams/datastreamtest.cpp +++ b/tests/streams/datastreamtest.cpp @@ -248,9 +248,11 @@ void DataStreamTestCase::StringRW() wxString s(wxT("Test1")); CPPUNIT_ASSERT_EQUAL( TestRW(s), s ); +#if wxUSE_UNICODE s.append(2, wxT('\0')); s.append(wxT("Test2")); CPPUNIT_ASSERT_EQUAL( TestRW(s), s ); +#endif // wxUSE_UNICODE s = wxString::FromUTF8("\xc3\xbc"); // U+00FC LATIN SMALL LETTER U WITH DIAERESIS CPPUNIT_ASSERT_EQUAL( TestRW(s), s ); diff --git a/tests/streams/sstream.cpp b/tests/streams/sstream.cpp index 1bff584180..a17640c3e8 100644 --- a/tests/streams/sstream.cpp +++ b/tests/streams/sstream.cpp @@ -131,7 +131,7 @@ TEST_CASE("wxStringOutputStream::Tell", "[stream]") wxString str(s); CHECK( wxStringOutputStream(&str).TellO() == len ); - +#if wxUSE_UNICODE wxMBConvUTF16 convUTF16; wxStringOutputStream ss16(NULL, convUTF16); CHECK( ss16.TellO() == 0 ); @@ -144,4 +144,5 @@ TEST_CASE("wxStringOutputStream::Tell", "[stream]") // The U+2070D character is represented by a surrogate pair in UTF-16. wxString u2070D = wxString::FromUTF8("\xF0\xA0\x9C\x8D"); CHECK( wxStringOutputStream(&u2070D, convUTF16).TellO() == 4 ); +#endif // wxUSE_UNICODE } diff --git a/tests/strings/stdstrings.cpp b/tests/strings/stdstrings.cpp index 550684f5da..1f9a6b3d66 100644 --- a/tests/strings/stdstrings.cpp +++ b/tests/strings/stdstrings.cpp @@ -636,9 +636,11 @@ void StdStringTestCase::StdConversion() wxStdWideString s8(s4); CPPUNIT_ASSERT( s8 == "hello" ); +#if wxUSE_UNICODE std::string s9("\xF0\x9F\x90\xB1\0\xE7\x8C\xAB", 9); /* U+1F431 U+0000 U+732B */ wxString s10 = wxString::FromUTF8(s9); CPPUNIT_ASSERT_EQUAL( s9, s10.ToStdString(wxConvUTF8) ); +#endif // wxUSE_UNICODE std::string s11("xyz\0\xFF", 5); /* an invalid UTF-8 sequence */ CPPUNIT_ASSERT_EQUAL( wxString::FromUTF8(s11), "" ); diff --git a/tests/strings/strings.cpp b/tests/strings/strings.cpp index be7215905c..8bbe9d69ad 100644 --- a/tests/strings/strings.cpp +++ b/tests/strings/strings.cpp @@ -260,7 +260,9 @@ void StringTestCase::StaticConstructors() CPPUNIT_ASSERT_EQUAL( "Hello", wxString::FromUTF8("Hello", 5) ); CPPUNIT_ASSERT_EQUAL( "Hello", wxString::FromUTF8("Hello") ); +#if wxUSE_UNICODE CPPUNIT_ASSERT_EQUAL( 2, wxString::FromUTF8("h\xc3\xa9llo", 3).length() ); +#endif // wxUSE_UNICODE //CPPUNIT_ASSERT_EQUAL( 1, wxString::FromUTF8("", 1).length() );