diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2024-04-26 14:01:07 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2024-04-26 21:41:38 +0200 |
commit | 752ea376b0a1ee50c97ecc061d8bc507416838d0 (patch) | |
tree | 8d7e67680ae5a679aa5e67abbbcafb75c3f011fa /sal | |
parent | 105ce47a695cb7ea7e6abf879e1c632b7d81f054 (diff) |
loplugin:ostr in sal
Change-Id: I7732a77fc5ac8d1f5c53052e0f4b6c7e7d70f054
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/166739
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Tested-by: Jenkins
Diffstat (limited to 'sal')
28 files changed, 428 insertions, 437 deletions
diff --git a/sal/osl/unx/backtraceapi.cxx b/sal/osl/unx/backtraceapi.cxx index 4c1f25b886ae..008b5f5c7092 100644 --- a/sal/osl/unx/backtraceapi.cxx +++ b/sal/osl/unx/backtraceapi.cxx @@ -76,16 +76,16 @@ void process_file_addr2line( const char* file, std::vector<FrameData>& frameData { if(access( file, R_OK ) != 0) return; // cannot read info from the binary file anyway - OUString binary("addr2line"); + OUString binary(u"addr2line"_ustr); OUString dummy; #if defined __clang__ // llvm-addr2line is faster than addr2line - if(osl::detail::find_in_PATH("llvm-addr2line", dummy)) + if(osl::detail::find_in_PATH(u"llvm-addr2line"_ustr, dummy)) binary = "llvm-addr2line"; #endif if(!osl::detail::find_in_PATH(binary, dummy)) return; // Will not work, avoid warnings from osl process code. - OUString arg1("-Cfe"); + OUString arg1(u"-Cfe"_ustr); OUString arg2 = OUString::fromUtf8(file); std::vector<OUString> addrs; std::vector<rtl_uString*> args; diff --git a/sal/osl/unx/file_url.cxx b/sal/osl/unx/file_url.cxx index be98df95f14e..ffb1559356a8 100644 --- a/sal/osl/unx/file_url.cxx +++ b/sal/osl/unx/file_url.cxx @@ -732,7 +732,7 @@ namespace osl::detail { bool find_in_PATH(const OUString& file_path, OUString& result) { bool bfound = false; - OUString path("PATH"); + OUString path(u"PATH"_ustr); OUString env_path; if (osl_getEnvironment(path.pData, &env_path.pData) == osl_Process_E_None) diff --git a/sal/osl/unx/pipe.cxx b/sal/osl/unx/pipe.cxx index 4dfd75ddf662..618ca23ed108 100644 --- a/sal/osl/unx/pipe.cxx +++ b/sal/osl/unx/pipe.cxx @@ -132,7 +132,7 @@ getBootstrapSocketPath() { OUString pValue; - if (rtl::Bootstrap::get("OSL_SOCKET_PATH", pValue)) + if (rtl::Bootstrap::get(u"OSL_SOCKET_PATH"_ustr, pValue)) { return OUStringToOString(pValue, RTL_TEXTENCODING_UTF8); } diff --git a/sal/qa/osl/file/osl_File.cxx b/sal/qa/osl/file/osl_File.cxx index 6b0c50dfafd8..159f32ad7410 100644 --- a/sal/qa/osl/file/osl_File.cxx +++ b/sal/qa/osl/file/osl_File.cxx @@ -4296,7 +4296,7 @@ namespace osl_Directory // open a directory auto nError1 = testDirectory.open(); CPPUNIT_ASSERT_EQUAL(osl::FileBase::E_None, nError1); - OUString aFileName ("link.file"); + OUString aFileName (u"link.file"_ustr); while (true) { nError1 = testDirectory.getNextItem(rItem, 4); @@ -4783,7 +4783,7 @@ namespace osl_Directory void with_relative_path() { - osl::FileBase::RC rc = Directory::createPath(TEST_PATH_POSTFIX); + osl::FileBase::RC rc = Directory::createPath(u"" TEST_PATH_POSTFIX ""_ustr); CPPUNIT_ASSERT_EQUAL_MESSAGE ( diff --git a/sal/qa/osl/file/osl_File_Const.h b/sal/qa/osl/file/osl_File_Const.h index beee8d6d62d5..fb9ad6d6a2db 100644 --- a/sal/qa/osl/file/osl_File_Const.h +++ b/sal/qa/osl/file/osl_File_Const.h @@ -113,10 +113,10 @@ const char pBuffer_Blank[] = ""; // OS independent file definition -OUString aNullURL( "" ); -OUString aSlashURL( PATH_SEPARATOR ); -OUString aPreURL( FILE_PREFIX ); -OUString aRootURL( FILE_PREFIX TEST_PLATFORM_ROOT ); +OUString aNullURL( u""_ustr ); +OUString aSlashURL( u"" PATH_SEPARATOR ""_ustr ); +OUString aPreURL( u"" FILE_PREFIX ""_ustr ); +OUString aRootURL( u"" FILE_PREFIX TEST_PLATFORM_ROOT ""_ustr ); OUString aTempDirectorySys(getTempDirectorySys_()); OUString aTempDirectoryURL(getTempDirectoryURL_()); @@ -128,10 +128,10 @@ OUString aUserDirectoryURL( aTempDirectoryURL + "" ); OUString aCanURL1( aTempDirectoryURL + "/canonical.name" ); OUString aCanURL2( RTL_CONSTASCII_USTRINGPARAM("ca@#;+.,$///78no\0ni..name")); -OUString aCanURL3( "ca@#;+.,$//tmp/678nonical//name" ); -OUString aCanURL4( "canonical.name" ); -OUString aTmpName1( "tmpdir" ); -OUString aTmpName2( "tmpname" ); +OUString aCanURL3( u"ca@#;+.,$//tmp/678nonical//name"_ustr ); +OUString aCanURL4( u"canonical.name"_ustr ); +OUString aTmpName1( u"tmpdir"_ustr ); +OUString aTmpName2( u"tmpname"_ustr ); OUString aTmpName3( aTempDirectoryURL + "/tmpdir" ); OUString aTmpName4( aTempDirectoryURL + "/tmpdir/tmpname" ); OUString aTmpName5( aTempDirectoryURL + "/tmpdir/../tmpdir/./tmpname" ); @@ -141,17 +141,17 @@ OUString aTmpName8( aTempDirectoryURL + "/tmpname/tmpdir" ); OUString aTmpName9( aTempDirectoryURL + "/tmpdir/../tmpdir/./" ); OUString aTmpName10(aTempDirectoryURL + u"/\xE6\x9C\xAA\xE5\x91\xBD\xE5\x90\x8Dzhgb18030"); -OUString aRelURL1( "relative/file1" ); -OUString aRelURL2( "relative/./file2" ); -OUString aRelURL3( "relative/../file3" ); -OUString aRelURL4( "././relative/../file4" ); +OUString aRelURL1( u"relative/file1"_ustr ); +OUString aRelURL2( u"relative/./file2"_ustr ); +OUString aRelURL3( u"relative/../file3"_ustr ); +OUString aRelURL4( u"././relative/../file4"_ustr ); OUString aRelURL5( aTempDirectoryURL + "/./../" ); OUString aLnkURL1( aTempDirectoryURL + "/link.file" ); -OUString aHidURL1( ".hiddenfile" ); +OUString aHidURL1( u".hiddenfile"_ustr ); // common used System Path:temp, root,etc -OUString aRootSys( TEST_PLATFORM_ROOT ); +OUString aRootSys( u"" TEST_PLATFORM_ROOT ""_ustr); OUString aSysPath1( aTempDirectorySys + "/system.path" ); OUString aSysPath2( aTempDirectorySys + "/system/path" ); OUString aSysPath3( aTempDirectorySys + "/tmpdir" ); @@ -165,36 +165,36 @@ OUString aFifoSys( aTempDirectorySys + "/tmpdir/fifo" ); // Note that this may be changed in the different platform, so be careful to use. #if ( defined UNX ) // Unix -OUString aTypeURL1( FILE_PREFIX "dev/ccv"); //socket Solaris/Linux -OUString aTypeURL2( FILE_PREFIX "devices/pseudo/tcp@0:tcp"); //special Solaris/Linux -OUString aTypeURL3( FILE_PREFIX "lib" ); //link Solaris +OUString aTypeURL1( u"" FILE_PREFIX "dev/ccv"_ustr); //socket Solaris/Linux +OUString aTypeURL2( u"" FILE_PREFIX "devices/pseudo/tcp@0:tcp"_ustr); //special Solaris/Linux +OUString aTypeURL3( u"" FILE_PREFIX "lib"_ustr ); //link Solaris #else // Windows -OUString aTypeURL1( FILE_PREFIX "" ); -OUString aTypeURL2( FILE_PREFIX "" ); -OUString aTypeURL3( FILE_PREFIX "" ); +OUString aTypeURL1( u"" FILE_PREFIX ""_ustr ); +OUString aTypeURL2( u"" FILE_PREFIX ""_ustr ); +OUString aTypeURL3( u"" FILE_PREFIX ""_ustr ); #endif // Volume device URL, we pick some canonical volume device for test: // UNIX file system, Floppy Disk, Proc file system, Temp file system, Compact Disk. #if ( defined UNX ) // Unix -OUString aVolURL1( FILE_PREFIX ""); //ufs Solaris/Linux +OUString aVolURL1( u"" FILE_PREFIX ""_ustr); //ufs Solaris/Linux #ifdef __sun -OUString aVolURL2( FILE_PREFIX "dev/fd" ); //fd Solaris +OUString aVolURL2( u"" FILE_PREFIX "dev/fd"_ustr ); //fd Solaris #else -OUString aVolURL2( FILE_PREFIX "dev/floppy/0u1440" ); //fd0 Linux +OUString aVolURL2( u"" FILE_PREFIX "dev/floppy/0u1440"_ustr ); //fd0 Linux #endif -OUString aVolURL3( FILE_PREFIX "proc" ); //proc Solaris/Linux -OUString aVolURL4( FILE_PREFIX "staroffice" ); //nfs Solaris/Linux -OUString aVolURL5( FILE_PREFIX "tmp" ); //tmpfs Solaris -OUString aVolURL6( FILE_PREFIX "cdrom" ); //cd Solaris +OUString aVolURL3( u"" FILE_PREFIX "proc"_ustr ); //proc Solaris/Linux +OUString aVolURL4( u"" FILE_PREFIX "staroffice"_ustr ); //nfs Solaris/Linux +OUString aVolURL5( u"" FILE_PREFIX "tmp"_ustr ); //tmpfs Solaris +OUString aVolURL6( u"" FILE_PREFIX "cdrom"_ustr ); //cd Solaris #else // Windows -OUString aVolURL1( FILE_PREFIX "c:/" ); -OUString aVolURL2( FILE_PREFIX "a:/" ); -OUString aVolURL3( FILE_PREFIX "" ); -OUString aVolURL4( FILE_PREFIX "" ); -OUString aVolURL5( FILE_PREFIX "c:/temp" ); -OUString aVolURL6( FILE_PREFIX "e:/" ); +OUString aVolURL1( u"" FILE_PREFIX "c:/"_ustr ); +OUString aVolURL2( u"" FILE_PREFIX "a:/"_ustr ); +OUString aVolURL3( u"" FILE_PREFIX ""_ustr ); +OUString aVolURL4( u"" FILE_PREFIX ""_ustr ); +OUString aVolURL5( u"" FILE_PREFIX "c:/temp"_ustr ); +OUString aVolURL6( u"" FILE_PREFIX "e:/"_ustr ); #endif #ifdef __cplusplus diff --git a/sal/qa/osl/file/osl_old_test_file.cxx b/sal/qa/osl/file/osl_old_test_file.cxx index bb37e8f3384a..871e8913689e 100644 --- a/sal/qa/osl/file/osl_old_test_file.cxx +++ b/sal/qa/osl/file/osl_old_test_file.cxx @@ -74,7 +74,7 @@ const std::pair<OUString, OUString> aSource2[] = { void oldtestfile::test_file_001() { - OUString base1( "file:///" TEST_VOLUME "bla" ); + OUString base1( u"file:///" TEST_VOLUME "bla"_ustr ); for (const auto& [rel, expected] : aSource1) { OUString target; @@ -86,7 +86,7 @@ void oldtestfile::test_file_001() void oldtestfile::test_file_002() { - OUString base2( "file:///" TEST_VOLUME "bla/blubs/schnubbel" ); + OUString base2( u"file:///" TEST_VOLUME "bla/blubs/schnubbel"_ustr ); for (const auto& [rel, expected] : aSource2) { OUString target; @@ -98,7 +98,7 @@ void oldtestfile::test_file_002() void oldtestfile::test_file_004() { - OUString base4( "file:///" TEST_VOLUME "bla/" ); + OUString base4( u"file:///" TEST_VOLUME "bla/"_ustr ); for (const auto& [rel, expected] : aSource1) { OUString target; diff --git a/sal/qa/osl/getsystempathfromfileurl/test-getsystempathfromfileurl.cxx b/sal/qa/osl/getsystempathfromfileurl/test-getsystempathfromfileurl.cxx index d4adff6531a5..648047850387 100644 --- a/sal/qa/osl/getsystempathfromfileurl/test-getsystempathfromfileurl.cxx +++ b/sal/qa/osl/getsystempathfromfileurl/test-getsystempathfromfileurl.cxx @@ -84,7 +84,7 @@ private: void Test::testBadScheme() { OUString p; - auto e = osl::FileBase::getSystemPathFromFileURL("foo:bar", p); + auto e = osl::FileBase::getSystemPathFromFileURL(u"foo:bar"_ustr, p); CPPUNIT_ASSERT_EQUAL(osl::FileBase::E_INVAL, e); CPPUNIT_ASSERT_EQUAL(OUString(), p); } @@ -92,9 +92,9 @@ void Test::testBadScheme() { void Test::testNoScheme() { #if !defined(_WIN32) //TODO OUString p; - auto e = osl::FileBase::getSystemPathFromFileURL("//" MY_PATH_IN, p); + auto e = osl::FileBase::getSystemPathFromFileURL(u"//" MY_PATH_IN ""_ustr, p); CPPUNIT_ASSERT_EQUAL(osl::FileBase::E_None, e); - CPPUNIT_ASSERT_EQUAL(OUString(MY_PATH_OUT), p); + CPPUNIT_ASSERT_EQUAL(u"" MY_PATH_OUT ""_ustr, p); #endif } @@ -102,7 +102,7 @@ void Test::testBadAuthority() { #if defined UNX OUString p; auto e = osl::FileBase::getSystemPathFromFileURL( - "file://baz" MY_PATH_IN, p); + u"file://baz" MY_PATH_IN ""_ustr, p); CPPUNIT_ASSERT_EQUAL(osl::FileBase::E_INVAL, e); CPPUNIT_ASSERT_EQUAL(OUString(), p); #endif @@ -111,50 +111,50 @@ void Test::testBadAuthority() { void Test::testLocalhost1Authority() { OUString p; auto e = osl::FileBase::getSystemPathFromFileURL( - "file://localhost" MY_PATH_IN, p); + u"file://localhost" MY_PATH_IN ""_ustr, p); CPPUNIT_ASSERT_EQUAL(osl::FileBase::E_None, e); - CPPUNIT_ASSERT_EQUAL(OUString(MY_PATH_OUT), p); + CPPUNIT_ASSERT_EQUAL(u"" MY_PATH_OUT ""_ustr, p); } void Test::testLocalhost2Authority() { OUString p; auto e = osl::FileBase::getSystemPathFromFileURL( - "file://LOCALHOST" MY_PATH_IN, p); + u"file://LOCALHOST" MY_PATH_IN ""_ustr, p); CPPUNIT_ASSERT_EQUAL(osl::FileBase::E_None, e); - CPPUNIT_ASSERT_EQUAL(OUString(MY_PATH_OUT), p); + CPPUNIT_ASSERT_EQUAL(u"" MY_PATH_OUT ""_ustr, p); } void Test::testLocalhost3Authority() { OUString p; auto e = osl::FileBase::getSystemPathFromFileURL( - "file://127.0.0.1" MY_PATH_IN, p); + u"file://127.0.0.1" MY_PATH_IN ""_ustr, p); CPPUNIT_ASSERT_EQUAL(osl::FileBase::E_None, e); - CPPUNIT_ASSERT_EQUAL(OUString(MY_PATH_OUT), p); + CPPUNIT_ASSERT_EQUAL(u"" MY_PATH_OUT ""_ustr, p); } void Test::testNoAuthority() { OUString p; - auto e = osl::FileBase::getSystemPathFromFileURL("file:" MY_PATH_IN, p); + auto e = osl::FileBase::getSystemPathFromFileURL(u"file:" MY_PATH_IN ""_ustr, p); CPPUNIT_ASSERT_EQUAL(osl::FileBase::E_None, e); - CPPUNIT_ASSERT_EQUAL(OUString(MY_PATH_OUT), p); + CPPUNIT_ASSERT_EQUAL(u"" MY_PATH_OUT ""_ustr, p); } void Test::testEmptyPath() { #if defined UNX OUString p; - auto e = osl::FileBase::getSystemPathFromFileURL("file://", p); + auto e = osl::FileBase::getSystemPathFromFileURL(u"file://"_ustr, p); CPPUNIT_ASSERT_EQUAL(osl::FileBase::E_None, e); - CPPUNIT_ASSERT_EQUAL(OUString("/"), p); + CPPUNIT_ASSERT_EQUAL(u"/"_ustr, p); #endif } void Test::testHomeAbbreviation() { #if defined UNX OUString p; - auto e = osl::FileBase::getSystemPathFromFileURL("file:///~", p); + auto e = osl::FileBase::getSystemPathFromFileURL(u"file:///~"_ustr, p); CPPUNIT_ASSERT_EQUAL(osl::FileBase::E_None, e); // could theoretically fail due to osl::Security::getHomeDir problem - e = osl::FileBase::getSystemPathFromFileURL("file:///~/foo%2525/bar", p); + e = osl::FileBase::getSystemPathFromFileURL(u"file:///~/foo%2525/bar"_ustr, p); CPPUNIT_ASSERT_EQUAL(osl::FileBase::E_None, e); // could theoretically fail due to osl::Security::getHomeDir problem CPPUNIT_ASSERT(p.endsWith("/foo%25/bar")); @@ -165,7 +165,7 @@ void Test::testOtherHomeAbbreviation() { #if defined UNX OUString p; auto e = osl::FileBase::getSystemPathFromFileURL( - "file:///~baz" MY_PATH_IN, p); + u"file:///~baz" MY_PATH_IN ""_ustr, p); CPPUNIT_ASSERT_EQUAL(osl::FileBase::E_INVAL, e); // not supported for now CPPUNIT_ASSERT_EQUAL(OUString(), p); #endif @@ -173,7 +173,7 @@ void Test::testOtherHomeAbbreviation() { void Test::testRelative() { OUString p; - auto e = osl::FileBase::getSystemPathFromFileURL("foo/bar", p); + auto e = osl::FileBase::getSystemPathFromFileURL(u"foo/bar"_ustr, p); CPPUNIT_ASSERT_EQUAL(osl::FileBase::E_None, e); CPPUNIT_ASSERT(p.endsWith(MY_PATH_OUT_REL)); } @@ -181,15 +181,15 @@ void Test::testRelative() { void Test::testEscape() { OUString p; auto e = osl::FileBase::getSystemPathFromFileURL( - "file://" MY_PATH_IN "/b%61z", p); + u"file://" MY_PATH_IN "/b%61z"_ustr, p); CPPUNIT_ASSERT_EQUAL(osl::FileBase::E_None, e); - CPPUNIT_ASSERT_EQUAL(OUString(MY_PATH_OUT_CONT "baz"), p); + CPPUNIT_ASSERT_EQUAL(u"" MY_PATH_OUT_CONT "baz" ""_ustr, p); } void Test::testBadEscape2f() { OUString p; auto e = osl::FileBase::getSystemPathFromFileURL( - "file://" MY_PATH_IN "/b%2fz", p); + u"file://" MY_PATH_IN "/b%2fz"_ustr, p); CPPUNIT_ASSERT_EQUAL(osl::FileBase::E_INVAL, e); CPPUNIT_ASSERT_EQUAL(OUString(), p); } @@ -197,7 +197,7 @@ void Test::testBadEscape2f() { void Test::testBadEscape2F() { OUString p; auto e = osl::FileBase::getSystemPathFromFileURL( - "file://" MY_PATH_IN "/b%2Fz", p); + u"file://" MY_PATH_IN "/b%2Fz"_ustr, p); CPPUNIT_ASSERT_EQUAL(osl::FileBase::E_INVAL, e); CPPUNIT_ASSERT_EQUAL(OUString(), p); } @@ -214,7 +214,7 @@ void Test::testBad0() { void Test::testBadEscape0() { OUString p; auto e = osl::FileBase::getSystemPathFromFileURL( - "file://" MY_PATH_IN "/b%00z", p); + u"file://" MY_PATH_IN "/b%00z"_ustr, p); CPPUNIT_ASSERT_EQUAL(osl::FileBase::E_INVAL, e); CPPUNIT_ASSERT_EQUAL(OUString(), p); } @@ -222,7 +222,7 @@ void Test::testBadEscape0() { void Test::testBadQuery() { OUString p; auto e = osl::FileBase::getSystemPathFromFileURL( - "file://" MY_PATH_IN "?baz", p); + u"file://" MY_PATH_IN "?baz"_ustr, p); CPPUNIT_ASSERT_EQUAL(osl::FileBase::E_INVAL, e); CPPUNIT_ASSERT_EQUAL(OUString(), p); } @@ -230,7 +230,7 @@ void Test::testBadQuery() { void Test::testBadFragment() { OUString p; auto e = osl::FileBase::getSystemPathFromFileURL( - "file://" MY_PATH_IN "#baz", p); + u"file://" MY_PATH_IN "#baz"_ustr, p); CPPUNIT_ASSERT_EQUAL(osl::FileBase::E_INVAL, e); CPPUNIT_ASSERT_EQUAL(OUString(), p); } diff --git a/sal/qa/osl/module/osl_Module.cxx b/sal/qa/osl/module/osl_Module.cxx index f440a715162f..3e9ad810717f 100644 --- a/sal/qa/osl/module/osl_Module.cxx +++ b/sal/qa/osl/module/osl_Module.cxx @@ -30,7 +30,7 @@ static OUString getDllURL() #if defined(_WIN32) // lib in Unix and lib in Windows are not same in file name. OUString libPath( "test_Module_DLL.dll" ); #else - OUString libPath( "libtest_Module_DLL.so" ); + OUString libPath( u"libtest_Module_DLL.so"_ustr ); #endif OUString dirPath, dllPath; @@ -136,7 +136,7 @@ namespace osl_Module #if !defined( MACOSX ) // TODO: Find out why this fails on macOS ::osl::Module aMod( getDllURL( ) ); - FuncPtr pFunc = reinterpret_cast<FuncPtr>(aMod.getSymbol( "firstfunc" )); + FuncPtr pFunc = reinterpret_cast<FuncPtr>(aMod.getSymbol( u"firstfunc"_ustr )); OUString aFileURL; bRes = osl::Module::getUrlFromAddress( @@ -265,7 +265,7 @@ namespace osl_Module #if !defined( MACOSX ) // TODO: Find out why this fails on macOS ::osl::Module aMod( getDllURL( ) ); - FuncPtr pFunc = reinterpret_cast<FuncPtr>(aMod.getSymbol( "firstfunc" )); + FuncPtr pFunc = reinterpret_cast<FuncPtr>(aMod.getSymbol( u"firstfunc"_ustr )); bRes = false; if ( pFunc ) bRes = pFunc( bRes ); @@ -313,7 +313,7 @@ namespace osl_Module #if !defined( MACOSX ) // TODO: Find out why this fails on macOS ::osl::Module aMod( getDllURL( ) ); - OUString funcName( "firstfunc" ); + OUString funcName( u"firstfunc"_ustr ); FuncPtr pFunc = reinterpret_cast<FuncPtr>(osl_getSymbol( static_cast<oslModule>(aMod), funcName.pData )); bRes = false; diff --git a/sal/qa/osl/process/osl_process.cxx b/sal/qa/osl/process/osl_process.cxx index f30b854a42f2..9f4bbf3a78fc 100644 --- a/sal/qa/osl/process/osl_process.cxx +++ b/sal/qa/osl/process/osl_process.cxx @@ -149,7 +149,7 @@ public: // ctor Test_osl_executeProcess() : - env_param_(OUString("-env")), suCWD(getExecutablePath()) + env_param_(u"-env"_ustr), suCWD(getExecutablePath()) { parameters_[0] = env_param_.pData; @@ -330,10 +330,10 @@ public: void osl_execProc_merged_child_environment() { rtl_uString* child_env[4]; - OUString env1(ENV1); - OUString env2(ENV2); - OUString env3(ENV3); - OUString env4(ENV4); + OUString env1(u"" ENV1 ""_ustr); + OUString env2(u"" ENV2 ""_ustr); + OUString env3(u"" ENV3 ""_ustr); + OUString env4(u"" ENV4 ""_ustr); child_env[0] = env1.pData; child_env[1] = env2.pData; diff --git a/sal/qa/osl/profile/osl_old_testprofile.cxx b/sal/qa/osl/profile/osl_old_testprofile.cxx index 6d44ebde4c7f..077a60851dbc 100644 --- a/sal/qa/osl/profile/osl_old_testprofile.cxx +++ b/sal/qa/osl/profile/osl_old_testprofile.cxx @@ -39,7 +39,7 @@ namespace osl_Profile void oldtests::test_profile() { OUString baseUrl; - CPPUNIT_ASSERT(rtl::Bootstrap::get("UserInstallation", baseUrl)); + CPPUNIT_ASSERT(rtl::Bootstrap::get(u"UserInstallation"_ustr, baseUrl)); // successful write oslProfile hProfile = osl_openProfile( OUString(baseUrl + "/soffice.ini").pData, osl_Profile_WRITELOCK ); diff --git a/sal/qa/osl/socket.cxx b/sal/qa/osl/socket.cxx index 4598754a2214..16b1366ba884 100644 --- a/sal/qa/osl/socket.cxx +++ b/sal/qa/osl/socket.cxx @@ -45,7 +45,7 @@ class SocketTest : public CppUnit::TestFixture OUString out; auto const res = osl_getDottedInetAddrOfSocketAddr(addr, &out.pData); CPPUNIT_ASSERT_EQUAL(osl_Socket_Ok, res); - CPPUNIT_ASSERT_EQUAL(OUString("123.255.255.255"), out); + CPPUNIT_ASSERT_EQUAL(u"123.255.255.255"_ustr, out); CPPUNIT_ASSERT_EQUAL(sal_Int32(100), osl_getInetPortOfSocketAddr(addr)); osl_destroySocketAddr(addr); } diff --git a/sal/qa/rtl/alloc/rtl_alloc.cxx b/sal/qa/rtl/alloc/rtl_alloc.cxx index 39d2b95f030a..cf4813ae16bf 100644 --- a/sal/qa/rtl/alloc/rtl_alloc.cxx +++ b/sal/qa/rtl/alloc/rtl_alloc.cxx @@ -158,7 +158,7 @@ public: rtl_alloc_preInit(true); - OUString aFoo("foo"); + OUString aFoo("foo"); // [-loplugin:ostr] // fill some cache bits for (int iter = 0; iter < 4; iter++) diff --git a/sal/qa/rtl/bootstrap/expand.cxx b/sal/qa/rtl/bootstrap/expand.cxx index 46ea08b331c6..cb9acb3a200f 100644 --- a/sal/qa/rtl/bootstrap/expand.cxx +++ b/sal/qa/rtl/bootstrap/expand.cxx @@ -33,21 +33,21 @@ private: }; void Test::setUp() { - rtl::Bootstrap::set("TEST", "<expanded TEST>"); - rtl::Bootstrap::set("WITH_DOLLAR", "foo\\$TEST"); - rtl::Bootstrap::set("INDIRECT", "$WITH_DOLLAR"); + rtl::Bootstrap::set(u"TEST"_ustr, u"<expanded TEST>"_ustr); + rtl::Bootstrap::set(u"WITH_DOLLAR"_ustr, u"foo\\$TEST"_ustr); + rtl::Bootstrap::set(u"INDIRECT"_ustr, u"$WITH_DOLLAR"_ustr); } void Test::testDollar() { - OUString s("$WITH_DOLLAR"); + OUString s(u"$WITH_DOLLAR"_ustr); rtl::Bootstrap::expandMacros(s); - CPPUNIT_ASSERT_EQUAL(OUString("foo$TEST"), s); + CPPUNIT_ASSERT_EQUAL(u"foo$TEST"_ustr, s); } void Test::testIndirectDollar() { - OUString s("$INDIRECT"); + OUString s(u"$INDIRECT"_ustr); rtl::Bootstrap::expandMacros(s); - CPPUNIT_ASSERT_EQUAL(OUString("foo$TEST"), s); + CPPUNIT_ASSERT_EQUAL(u"foo$TEST"_ustr, s); } CPPUNIT_TEST_SUITE_REGISTRATION(Test); diff --git a/sal/qa/rtl/doublelock/rtl_doublelocking.cxx b/sal/qa/rtl/doublelock/rtl_doublelocking.cxx index 0e2dd77cdcc5..60a5161c6661 100644 --- a/sal/qa/rtl/doublelock/rtl_doublelocking.cxx +++ b/sal/qa/rtl/doublelock/rtl_doublelocking.cxx @@ -43,7 +43,7 @@ namespace { struct Gregorian : public rtl::StaticWithInit<OUString, Gregorian> { OUString operator () () { - return CONST_TEST_STRING; + return u"" CONST_TEST_STRING ""_ustr; } }; @@ -61,7 +61,7 @@ public: OGetThread() :m_nOK(0), m_nFails(0), - m_sConstStr(CONST_TEST_STRING) + m_sConstStr(u"" CONST_TEST_STRING ""_ustr) { } diff --git a/sal/qa/rtl/locale/rtl_locale.cxx b/sal/qa/rtl/locale/rtl_locale.cxx index 4d8e1d63d3e4..2bc04c14fa6b 100644 --- a/sal/qa/rtl/locale/rtl_locale.cxx +++ b/sal/qa/rtl/locale/rtl_locale.cxx @@ -106,13 +106,13 @@ public: { rtl_Locale* pData = rtl_locale_getDefault(); OUString suLanguage = pData->Language; - CPPUNIT_ASSERT_EQUAL_MESSAGE( "locale language must be 'de'", OUString("de"), suLanguage ); + CPPUNIT_ASSERT_EQUAL_MESSAGE( "locale language must be 'de'", u"de"_ustr, suLanguage ); } void getLanguage_002() { rtl_Locale* pData = rtl_locale_getDefault(); OUString suLanguage(rtl_locale_getLanguage(pData), SAL_NO_ACQUIRE); - CPPUNIT_ASSERT_EQUAL_MESSAGE( "locale language must be 'de'", OUString("de"), suLanguage ); + CPPUNIT_ASSERT_EQUAL_MESSAGE( "locale language must be 'de'", u"de"_ustr, suLanguage ); } // Change the following lines only, if you add, remove or rename @@ -140,13 +140,13 @@ public: { rtl_Locale* pData = rtl_locale_getDefault(); OUString suCountry = pData->Country; - CPPUNIT_ASSERT_EQUAL_MESSAGE( "locale country must be 'DE'", OUString("DE"), suCountry ); + CPPUNIT_ASSERT_EQUAL_MESSAGE( "locale country must be 'DE'", u"DE"_ustr, suCountry ); } void getCountry_002() { rtl_Locale* pData = rtl_locale_getDefault(); OUString suCountry(rtl_locale_getCountry(pData), SAL_NO_ACQUIRE); - CPPUNIT_ASSERT_EQUAL_MESSAGE( "locale country must be 'DE'", OUString("DE"), suCountry ); + CPPUNIT_ASSERT_EQUAL_MESSAGE( "locale country must be 'DE'", u"DE"_ustr, suCountry ); } // Change the following lines only, if you add, remove or rename @@ -174,13 +174,13 @@ public: { rtl_Locale* pData = rtl_locale_getDefault(); OUString suVariant = pData->Variant; - CPPUNIT_ASSERT_EQUAL_MESSAGE( "locale variant must be 'hochdeutsch'", OUString("hochdeutsch"), suVariant ); + CPPUNIT_ASSERT_EQUAL_MESSAGE( "locale variant must be 'hochdeutsch'", u"hochdeutsch"_ustr, suVariant ); } void getVariant_002() { rtl_Locale* pData = rtl_locale_getDefault(); OUString suVariant(rtl_locale_getVariant(pData), SAL_NO_ACQUIRE); - CPPUNIT_ASSERT_EQUAL_MESSAGE( "locale variant must be 'hochdeutsch'", OUString("hochdeutsch"), suVariant ); + CPPUNIT_ASSERT_EQUAL_MESSAGE( "locale variant must be 'hochdeutsch'", u"hochdeutsch"_ustr, suVariant ); } // Change the following lines only, if you add, remove or rename diff --git a/sal/qa/rtl/math/test-rtl-math.cxx b/sal/qa/rtl/math/test-rtl-math.cxx index a5ce3b4e6262..ce73edb4799e 100644 --- a/sal/qa/rtl/math/test-rtl-math.cxx +++ b/sal/qa/rtl/math/test-rtl-math.cxx @@ -314,21 +314,21 @@ public: rtl_math_StringFormat_Automatic, rtl_math_DecimalPlaces_Max, '.', aGroups, ',', true)); - CPPUNIT_ASSERT_EQUAL( OUString("99,99,99,99,99,99,999"), aRes); + CPPUNIT_ASSERT_EQUAL( u"99,99,99,99,99,99,999"_ustr, aRes); fVal = 949.0; aRes = rtl::math::doubleToUString( fVal, rtl_math_StringFormat_Automatic, -2, // round before decimals '.', aGroups, ',', true); - CPPUNIT_ASSERT_EQUAL( OUString("900"), aRes); + CPPUNIT_ASSERT_EQUAL( u"900"_ustr, aRes); fVal = 950.0; aRes = rtl::math::doubleToUString( fVal, rtl_math_StringFormat_Automatic, -2, // round before decimals '.', aGroups, ',', true); - CPPUNIT_ASSERT_EQUAL( OUString("1,000"), aRes); + CPPUNIT_ASSERT_EQUAL( u"1,000"_ustr, aRes); // Check non-ASCII separators: Arabic decimal separator U+066B, thousand separator U+066C fVal = 123456.78; @@ -342,141 +342,141 @@ public: aRes = rtl::math::doubleToUString( fVal, rtl_math_StringFormat_Automatic, rtl_math_DecimalPlaces_Max, '.'); - CPPUNIT_ASSERT_EQUAL( OUString("4503599627370495"), aRes); + CPPUNIT_ASSERT_EQUAL( u"4503599627370495"_ustr, aRes); fVal = 4503599627370496.0; aRes = rtl::math::doubleToUString( fVal, rtl_math_StringFormat_Automatic, 2, '.'); - CPPUNIT_ASSERT_EQUAL( OUString("4503599627370496.00"), aRes); + CPPUNIT_ASSERT_EQUAL( u"4503599627370496.00"_ustr, aRes); fVal = -4503599627370496.0; aRes = rtl::math::doubleToUString( fVal, rtl_math_StringFormat_Automatic, 2, '.'); - CPPUNIT_ASSERT_EQUAL( OUString("-4503599627370496.00"), aRes); + CPPUNIT_ASSERT_EQUAL( u"-4503599627370496.00"_ustr, aRes); fVal = 9007199254740991.0; // (2^53)-1 aRes = rtl::math::doubleToUString( fVal, rtl_math_StringFormat_Automatic, rtl_math_DecimalPlaces_Max, '.', true); - CPPUNIT_ASSERT_EQUAL( OUString("9007199254740991"), aRes); + CPPUNIT_ASSERT_EQUAL( u"9007199254740991"_ustr, aRes); fVal = 9007199254740992.0; // (2^53), algorithm switch aRes = rtl::math::doubleToUString( fVal, rtl_math_StringFormat_Automatic, rtl_math_DecimalPlaces_Max, '.', true); - CPPUNIT_ASSERT_EQUAL( OUString("9.00719925474099E+015"), aRes); + CPPUNIT_ASSERT_EQUAL( u"9.00719925474099E+015"_ustr, aRes); fVal = 9007199254740993.0; // (2^53)+1 would be but is 9007199254740992 aRes = rtl::math::doubleToUString( fVal, rtl_math_StringFormat_Automatic, rtl_math_DecimalPlaces_Max, '.', true); - CPPUNIT_ASSERT_EQUAL( OUString("9.00719925474099E+015"), aRes); + CPPUNIT_ASSERT_EQUAL( u"9.00719925474099E+015"_ustr, aRes); // Test rtl_math_StringFormat_G fVal = 0.001234567; aRes = rtl::math::doubleToUString( fVal, rtl_math_StringFormat_G, 3, '.', true); - CPPUNIT_ASSERT_EQUAL( OUString("0.00123"), aRes); + CPPUNIT_ASSERT_EQUAL( u"0.00123"_ustr, aRes); fVal = 123.4567; aRes = rtl::math::doubleToUString( fVal, rtl_math_StringFormat_G, 3, '.', true); - CPPUNIT_ASSERT_EQUAL( OUString("123"), aRes); + CPPUNIT_ASSERT_EQUAL( u"123"_ustr, aRes); fVal = 123.4567; aRes = rtl::math::doubleToUString( fVal, rtl_math_StringFormat_G, 4, '.', true); - CPPUNIT_ASSERT_EQUAL( OUString("123.5"), aRes); + CPPUNIT_ASSERT_EQUAL( u"123.5"_ustr, aRes); fVal = 99.6; aRes = rtl::math::doubleToUString( fVal, rtl_math_StringFormat_G, 3, '.', true); - CPPUNIT_ASSERT_EQUAL( OUString("99.6"), aRes); + CPPUNIT_ASSERT_EQUAL( u"99.6"_ustr, aRes); // Expected could be 1E+03 (as 999.6 rounded to 3 significant digits // results in 1000 with an exponent equal to significant digits). // Currently we don't and output 1000 instead, negligible. fVal = 999.6; aRes = rtl::math::doubleToUString( fVal, rtl_math_StringFormat_G, 3, '.', true); - CPPUNIT_ASSERT_EQUAL( OUString("1000"), aRes); + CPPUNIT_ASSERT_EQUAL( u"1000"_ustr, aRes); fVal = 9999.6; aRes = rtl::math::doubleToUString( fVal, rtl_math_StringFormat_G, 3, '.', true); - CPPUNIT_ASSERT_EQUAL( OUString("1E+004"), aRes); + CPPUNIT_ASSERT_EQUAL( u"1E+004"_ustr, aRes); fVal = 12345.6789; aRes = rtl::math::doubleToUString( fVal, rtl_math_StringFormat_G, -3, '.', true); - CPPUNIT_ASSERT_EQUAL( OUString("1.2E+004"), aRes); + CPPUNIT_ASSERT_EQUAL( u"1.2E+004"_ustr, aRes); // DBL_MAX and 4 nextafters fVal = DBL_MAX; aRes = rtl::math::doubleToUString( fVal, rtl_math_StringFormat_Automatic, rtl_math_DecimalPlaces_Max, '.', true); - CPPUNIT_ASSERT_EQUAL( OUString("1.7976931348623157E+308"), aRes); + CPPUNIT_ASSERT_EQUAL( u"1.7976931348623157E+308"_ustr, aRes); fVal = std::nextafter( fVal, 0); aRes = rtl::math::doubleToUString( fVal, rtl_math_StringFormat_Automatic, rtl_math_DecimalPlaces_Max, '.', true); - CPPUNIT_ASSERT_EQUAL( OUString("1.7976931348623155E+308"), aRes); + CPPUNIT_ASSERT_EQUAL( u"1.7976931348623155E+308"_ustr, aRes); fVal = std::nextafter( fVal, 0); aRes = rtl::math::doubleToUString( fVal, rtl_math_StringFormat_Automatic, rtl_math_DecimalPlaces_Max, '.', true); - CPPUNIT_ASSERT_EQUAL( OUString("1.7976931348623153E+308"), aRes); + CPPUNIT_ASSERT_EQUAL( u"1.7976931348623153E+308"_ustr, aRes); fVal = std::nextafter( fVal, 0); aRes = rtl::math::doubleToUString( fVal, rtl_math_StringFormat_Automatic, rtl_math_DecimalPlaces_Max, '.', true); - CPPUNIT_ASSERT_EQUAL( OUString("1.7976931348623151E+308"), aRes); + CPPUNIT_ASSERT_EQUAL( u"1.7976931348623151E+308"_ustr, aRes); fVal = std::nextafter( fVal, 0); aRes = rtl::math::doubleToUString( fVal, rtl_math_StringFormat_Automatic, rtl_math_DecimalPlaces_Max, '.', true); - CPPUNIT_ASSERT_EQUAL( OUString("1.797693134862315E+308"), aRes); + CPPUNIT_ASSERT_EQUAL( u"1.797693134862315E+308"_ustr, aRes); CPPUNIT_ASSERT_EQUAL(fVal, rtl::math::stringToDouble(aRes, '.', ',')); // Test roundtrip // DBL_MAX and 4 nextafters rounded to 15 decimals fVal = DBL_MAX; aRes = rtl::math::doubleToUString( fVal, rtl_math_StringFormat_Automatic, 15, '.', true); - CPPUNIT_ASSERT_EQUAL( OUString("1.797693134862316E+308"), aRes); + CPPUNIT_ASSERT_EQUAL( u"1.797693134862316E+308"_ustr, aRes); fVal = std::nextafter( fVal, 0); aRes = rtl::math::doubleToUString( fVal, rtl_math_StringFormat_Automatic, 15, '.', true); - CPPUNIT_ASSERT_EQUAL( OUString("1.797693134862316E+308"), aRes); + CPPUNIT_ASSERT_EQUAL( u"1.797693134862316E+308"_ustr, aRes); fVal = std::nextafter( fVal, 0); aRes = rtl::math::doubleToUString( fVal, rtl_math_StringFormat_Automatic, 15, '.', true); - CPPUNIT_ASSERT_EQUAL( OUString("1.797693134862315E+308"), aRes); + CPPUNIT_ASSERT_EQUAL( u"1.797693134862315E+308"_ustr, aRes); fVal = std::nextafter( fVal, 0); aRes = rtl::math::doubleToUString( fVal, rtl_math_StringFormat_Automatic, 15, '.', true); - CPPUNIT_ASSERT_EQUAL( OUString("1.797693134862315E+308"), aRes); + CPPUNIT_ASSERT_EQUAL( u"1.797693134862315E+308"_ustr, aRes); fVal = std::nextafter( fVal, 0); aRes = rtl::math::doubleToUString( fVal, rtl_math_StringFormat_Automatic, 15, '.', true); - CPPUNIT_ASSERT_EQUAL( OUString("1.797693134862315E+308"), aRes); + CPPUNIT_ASSERT_EQUAL( u"1.797693134862315E+308"_ustr, aRes); // DBL_MAX rounded to 14 decimals fVal = DBL_MAX; aRes = rtl::math::doubleToUString( fVal, rtl_math_StringFormat_Automatic, 14, '.', true); - CPPUNIT_ASSERT_EQUAL( OUString("1.79769313486232E+308"), aRes); + CPPUNIT_ASSERT_EQUAL( u"1.79769313486232E+308"_ustr, aRes); // DBL_MAX rounded to 2 decimals fVal = DBL_MAX; aRes = rtl::math::doubleToUString( fVal, rtl_math_StringFormat_Automatic, 2, '.', true); - CPPUNIT_ASSERT_EQUAL( OUString("1.8E+308"), aRes); + CPPUNIT_ASSERT_EQUAL( u"1.8E+308"_ustr, aRes); // Crashed after commit eae24a9488814e77254d175c11fc4a138c1dbd30 fVal = 123456.789; aRes = rtl::math::doubleToUString(fVal, rtl_math_StringFormat_E, 2, '.', false); - CPPUNIT_ASSERT_EQUAL(OUString("1.23E+005"), aRes); + CPPUNIT_ASSERT_EQUAL(u"1.23E+005"_ustr, aRes); fVal = 9.9999999999999929; aRes = rtl::math::doubleToUString(fVal, rtl_math_StringFormat_Automatic, rtl_math_DecimalPlaces_Max, '.', true); - CPPUNIT_ASSERT_EQUAL(OUString("9.99999999999999"), aRes); + CPPUNIT_ASSERT_EQUAL(u"9.99999999999999"_ustr, aRes); fVal = 0.99999999999999933; aRes = rtl::math::doubleToUString(fVal, rtl_math_StringFormat_F, rtl_math_DecimalPlaces_Max, '.', true); - CPPUNIT_ASSERT_EQUAL(OUString("0.999999999999999"), aRes); + CPPUNIT_ASSERT_EQUAL(u"0.999999999999999"_ustr, aRes); } void test_approx() { diff --git a/sal/qa/rtl/oustring/rtl_OUString2.cxx b/sal/qa/rtl/oustring/rtl_OUString2.cxx index ee1b861a694e..505d4d7c701a 100644 --- a/sal/qa/rtl/oustring/rtl_OUString2.cxx +++ b/sal/qa/rtl/oustring/rtl_OUString2.cxx @@ -210,23 +210,21 @@ public: void test() { CPPUNIT_ASSERT_EQUAL( static_cast< sal_Int32 >(-0x76543210), - (OUString("-76543210"). + (u"-76543210"_ustr. toInt32(16))); // @return 0 if this string represents no number or one of too large magnitude CPPUNIT_ASSERT_EQUAL( static_cast< sal_Int32 >(0), - (OUString("+FEDCBA98"). + (u"+FEDCBA98"_ustr. toInt32(16))); CPPUNIT_ASSERT_EQUAL( static_cast< sal_Int64 >(-SAL_CONST_INT64(0x76543210FEDCBA98)), - (OUString( - "-76543210FEDCBA98"). + (u"-76543210FEDCBA98"_ustr. toInt64(16))); // @return 0 if this string represents no number or one of too large magnitude CPPUNIT_ASSERT_EQUAL( static_cast< sal_Int64 >(SAL_CONST_INT64(0)), - (OUString( - "+FEDCBA9876543210"). + (u"+FEDCBA9876543210"_ustr. toInt64(16))); } @@ -524,80 +522,80 @@ public: void lastIndexOf_test_oustring_offset_001() { // search for sun, start at the end, found (pos==0) - OUString aStr("sun java system"); - lastIndexOf_oustring_offset(aStr, "sun", 0, aStr.getLength()); + OUString aStr(u"sun java system"_ustr); + lastIndexOf_oustring_offset(aStr, u"sun"_ustr, 0, aStr.getLength()); } void lastIndexOf_test_oustring_offset_002() { // search for sun, start at pos = 3, found (pos==0) - lastIndexOf_oustring_offset("sun java system", "sun", 0, 3); + lastIndexOf_oustring_offset(u"sun java system"_ustr, u"sun"_ustr, 0, 3); } void lastIndexOf_test_oustring_offset_003() { // search for sun, start at pos = 2, found (pos==-1) - lastIndexOf_oustring_offset("sun java system", "sun", -1, 2); + lastIndexOf_oustring_offset(u"sun java system"_ustr, u"sun"_ustr, -1, 2); } void lastIndexOf_test_oustring_offset_004() { // search for sun, start at the end, found (pos==0) - lastIndexOf_oustring_offset("sun java system", "sun", -1, 1); + lastIndexOf_oustring_offset(u"sun java system"_ustr, u"sun"_ustr, -1, 1); } void lastIndexOf_test_oustring_001() { // search for sun, found (pos==0) - lastIndexOf_oustring("sun java system", "sun", 0); + lastIndexOf_oustring(u"sun java system"_ustr, u"sun"_ustr, 0); } void lastIndexOf_test_oustring_002() { // search for sun, found (pos==4) - lastIndexOf_oustring("the sun java system", "sun", 4); + lastIndexOf_oustring(u"the sun java system"_ustr, u"sun"_ustr, 4); } void lastIndexOf_test_oustring_003() { // search for sun, found (pos==8) - lastIndexOf_oustring("the sun sun java system", "sun", 8); + lastIndexOf_oustring(u"the sun sun java system"_ustr, u"sun"_ustr, 8); } void lastIndexOf_test_oustring_004() { // search for sun, found (pos==8) - lastIndexOf_oustring("the sun sun", "sun", 8); + lastIndexOf_oustring(u"the sun sun"_ustr, u"sun"_ustr, 8); } void lastIndexOf_test_oustring_005() { // search for sun, found (pos==4) - lastIndexOf_oustring("the sun su", "sun", 4); + lastIndexOf_oustring(u"the sun su"_ustr, u"sun"_ustr, 4); } void lastIndexOf_test_oustring_006() { // search for sun, found (pos==-1) - lastIndexOf_oustring("the su su", "sun", -1); + lastIndexOf_oustring(u"the su su"_ustr, u"sun"_ustr, -1); } void lastIndexOf_test_oustring_007() { // search for earth, not found (-1) - lastIndexOf_oustring("the su su", "earth", -1); + lastIndexOf_oustring(u"the su su"_ustr, u"earth"_ustr, -1); } void lastIndexOf_test_oustring_008() { // search for earth, not found (-1) - lastIndexOf_oustring("", "earth", -1); + lastIndexOf_oustring(u""_ustr, u"earth"_ustr, -1); } void lastIndexOf_test_oustring_009() { // search for earth, not found (-1) - lastIndexOf_oustring("", "", -1); + lastIndexOf_oustring(u""_ustr, u""_ustr, -1); } @@ -605,20 +603,20 @@ public: { // search for 's', found (19) sal_Unicode suChar = L's'; - lastIndexOf_salunicode("the sun sun java system", suChar, 19); + lastIndexOf_salunicode(u"the sun sun java system"_ustr, suChar, 19); } void lastIndexOf_test_salunicode_002() { // search for 'x', not found (-1) sal_Unicode suChar = L'x'; - lastIndexOf_salunicode("the sun sun java system", suChar, -1); + lastIndexOf_salunicode(u"the sun sun java system"_ustr, suChar, -1); } void lastIndexOf_test_salunicode_offset_001() { // search for 's', start from pos last char, found (19) - OUString aStr("the sun sun java system"); + OUString aStr(u"the sun sun java system"_ustr); sal_Unicode cuChar = L's'; lastIndexOf_salunicode_offset(aStr, cuChar, 19, aStr.getLength()); } @@ -626,13 +624,13 @@ public: { // search for 's', start pos is last occur from search behind, found (17) sal_Unicode cuChar = L's'; - lastIndexOf_salunicode_offset("the sun sun java system", cuChar, 17, 19); + lastIndexOf_salunicode_offset(u"the sun sun java system"_ustr, cuChar, 17, 19); } void lastIndexOf_test_salunicode_offset_003() { // search for 't', start pos is 1, found (0) sal_Unicode cuChar = L't'; - lastIndexOf_salunicode_offset("the sun sun java system", cuChar, 0, 1); + lastIndexOf_salunicode_offset(u"the sun sun java system"_ustr, cuChar, 0, 1); } // Change the following lines only, if you add, remove or rename @@ -686,66 +684,66 @@ public: void getToken_001() { - OUString suTokenStr("a;b"); + OUString suTokenStr(u"a;b"_ustr); sal_Int32 nIndex = 0; OUString suToken = suTokenStr.getToken( 0, ';', nIndex ); - CPPUNIT_ASSERT_EQUAL_MESSAGE( "Token should be a 'a'", OUString("a"), suToken); + CPPUNIT_ASSERT_EQUAL_MESSAGE( "Token should be a 'a'", u"a"_ustr, suToken); /* OUString */ suToken = suTokenStr.getToken( 0, ';', nIndex ); - CPPUNIT_ASSERT_EQUAL_MESSAGE( "Token should be a 'b'", OUString("b"), suToken); + CPPUNIT_ASSERT_EQUAL_MESSAGE( "Token should be a 'b'", u"b"_ustr, suToken); CPPUNIT_ASSERT_EQUAL_MESSAGE("index should be negative", static_cast<sal_Int32>(-1), nIndex); } void getToken_002() { - OUString suTokenStr("a;b.c"); + OUString suTokenStr(u"a;b.c"_ustr); sal_Int32 nIndex = 0; OUString suToken = suTokenStr.getToken( 0, ';', nIndex ); - CPPUNIT_ASSERT_EQUAL_MESSAGE( "Token should be a 'a'", OUString("a"), suToken ); + CPPUNIT_ASSERT_EQUAL_MESSAGE( "Token should be a 'a'", u"a"_ustr, suToken ); /* OUString */ suToken = suTokenStr.getToken( 0, '.', nIndex ); - CPPUNIT_ASSERT_EQUAL_MESSAGE( "Token should be a 'b'", OUString("b"), suToken ); + CPPUNIT_ASSERT_EQUAL_MESSAGE( "Token should be a 'b'", u"b"_ustr, suToken ); /* OUString */ suToken = suTokenStr.getToken( 0, '.', nIndex ); - CPPUNIT_ASSERT_EQUAL_MESSAGE( "Token should be a 'c'", OUString("c"), suToken ); + CPPUNIT_ASSERT_EQUAL_MESSAGE( "Token should be a 'c'", u"c"_ustr, suToken ); CPPUNIT_ASSERT_EQUAL_MESSAGE("index should be negative", static_cast<sal_Int32>(-1), nIndex); } void getToken_003() { - OUString suTokenStr("a;;b"); + OUString suTokenStr(u"a;;b"_ustr); sal_Int32 nIndex = 0; OUString suToken = suTokenStr.getToken( 0, ';', nIndex ); - CPPUNIT_ASSERT_EQUAL_MESSAGE( "Token should be a 'a'", OUString("a"), suToken ); + CPPUNIT_ASSERT_EQUAL_MESSAGE( "Token should be a 'a'", u"a"_ustr, suToken ); /* OUString */ suToken = suTokenStr.getToken( 0, ';', nIndex ); CPPUNIT_ASSERT_MESSAGE("Token should be empty", suToken.isEmpty()); /* OUString */ suToken = suTokenStr.getToken( 0, ';', nIndex ); - CPPUNIT_ASSERT_EQUAL_MESSAGE( "Token should be a 'b'", OUString("b"), suToken ); + CPPUNIT_ASSERT_EQUAL_MESSAGE( "Token should be a 'b'", u"b"_ustr, suToken ); CPPUNIT_ASSERT_EQUAL_MESSAGE("index should be negative", static_cast<sal_Int32>(-1), nIndex); } void getToken_004() { - OUString suTokenStr("longer.then.ever."); + OUString suTokenStr(u"longer.then.ever."_ustr); sal_Int32 nIndex = 0; OUString suToken = suTokenStr.getToken( 0, '.', nIndex ); - CPPUNIT_ASSERT_EQUAL_MESSAGE( "Token should be 'longer'", OUString("longer"), suToken ); + CPPUNIT_ASSERT_EQUAL_MESSAGE( "Token should be 'longer'", u"longer"_ustr, suToken ); /* OUString */ suToken = suTokenStr.getToken( 0, '.', nIndex ); - CPPUNIT_ASSERT_EQUAL_MESSAGE( "Token should be 'then'", OUString("then"), suToken ); + CPPUNIT_ASSERT_EQUAL_MESSAGE( "Token should be 'then'", u"then"_ustr, suToken ); /* OUString */ suToken = suTokenStr.getToken( 0, '.', nIndex ); - CPPUNIT_ASSERT_EQUAL_MESSAGE( "Token should be 'ever'", OUString("ever"), suToken ); + CPPUNIT_ASSERT_EQUAL_MESSAGE( "Token should be 'ever'", u"ever"_ustr, suToken ); /* OUString */ suToken = suTokenStr.getToken( 0, '.', nIndex ); CPPUNIT_ASSERT_MESSAGE("Token should be empty", suToken.isEmpty()); @@ -754,7 +752,7 @@ public: } void getToken_005() { - OUString ab("ab"); + OUString ab(u"ab"_ustr); sal_Int32 n = 0; CPPUNIT_ASSERT_EQUAL_MESSAGE( "token should be 'ab'", ab, ab.getToken(0, '-', n)); @@ -834,9 +832,9 @@ public: OUString().intern(); OUString::intern( "",strlen(""),RTL_TEXTENCODING_ASCII_US ); - OUString aFoo( "foo" ); + OUString aFoo( u"foo"_ustr ); OUString aFooIntern = aFoo.intern(); - CPPUNIT_ASSERT_EQUAL_MESSAGE( "string contents", OUString("foo"), aFooIntern); + CPPUNIT_ASSERT_EQUAL_MESSAGE( "string contents", u"foo"_ustr, aFooIntern); CPPUNIT_ASSERT_EQUAL_MESSAGE("string length", static_cast<sal_Int32>(3), aFooIntern.getLength()); // We have to dup due to no atomic 'intern' bit-set operation CPPUNIT_ASSERT_MESSAGE("intern dups", aFoo.pData != aFooIntern.pData); @@ -875,14 +873,14 @@ public: void indexOfAscii::test() { CPPUNIT_ASSERT_EQUAL(sal_Int32(-1), OUString().indexOf("")); CPPUNIT_ASSERT_EQUAL(sal_Int32(-1), OUString().lastIndexOf("")); - CPPUNIT_ASSERT_EQUAL(sal_Int32(0), OUString("foo").indexOf("foo")); - CPPUNIT_ASSERT_EQUAL(sal_Int32(0), OUString("foo").lastIndexOf("foo")); + CPPUNIT_ASSERT_EQUAL(sal_Int32(0), u"foo"_ustr.indexOf("foo")); + CPPUNIT_ASSERT_EQUAL(sal_Int32(0), u"foo"_ustr.lastIndexOf("foo")); CPPUNIT_ASSERT_EQUAL( - sal_Int32(2), OUString("fofoobar").indexOf("foo")); + sal_Int32(2), u"fofoobar"_ustr.indexOf("foo")); CPPUNIT_ASSERT_EQUAL( - sal_Int32(3), OUString("foofoofob").lastIndexOf("foo")); + sal_Int32(3), u"foofoofob"_ustr.lastIndexOf("foo")); CPPUNIT_ASSERT_EQUAL( - sal_Int32(3), OUString("foofoobar").indexOf("foo", 1)); + sal_Int32(3), u"foofoobar"_ustr.indexOf("foo", 1)); } class endsWith: public CppUnit::TestFixture { @@ -897,9 +895,9 @@ public: void endsWith::test() { CPPUNIT_ASSERT_EQUAL(true, OUString().endsWith("")); CPPUNIT_ASSERT_EQUAL(false, OUString().endsWith("foo")); - CPPUNIT_ASSERT_EQUAL(true, OUString("bar").endsWith("bar")); - CPPUNIT_ASSERT_EQUAL(true, OUString("foobar").endsWith("bar")); - CPPUNIT_ASSERT_EQUAL(false, OUString("FOOBAR").endsWith("bar")); + CPPUNIT_ASSERT_EQUAL(true, u"bar"_ustr.endsWith("bar")); + CPPUNIT_ASSERT_EQUAL(true, u"foobar"_ustr.endsWith("bar")); + CPPUNIT_ASSERT_EQUAL(false, u"FOOBAR"_ustr.endsWith("bar")); } class isEmpty: public CppUnit::TestFixture { @@ -1026,7 +1024,7 @@ void convertFromString::test() { (RTL_TEXTTOUNICODE_FLAGS_UNDEFINED_ERROR | RTL_TEXTTOUNICODE_FLAGS_MBUNDEFINED_ERROR | RTL_TEXTTOUNICODE_FLAGS_INVALID_ERROR))); - CPPUNIT_ASSERT_EQUAL( OUString("abc"), t ); + CPPUNIT_ASSERT_EQUAL( u"abc"_ustr, t ); } CPPUNIT_TEST_SUITE_REGISTRATION(rtl_OUString::number); diff --git a/sal/qa/rtl/oustring/rtl_ustr.cxx b/sal/qa/rtl/oustring/rtl_ustr.cxx index 9a7b2dbc5081..7932da98c840 100644 --- a/sal/qa/rtl/oustring/rtl_ustr.cxx +++ b/sal/qa/rtl/oustring/rtl_ustr.cxx @@ -41,8 +41,8 @@ namespace rtl_ustr void compare_002() { - OUString aStr1("Line must be equal."); - OUString aStr2("Line must be equal."); + OUString aStr1(u"Line must be equal."_ustr); + OUString aStr2(u"Line must be equal."_ustr); sal_Int32 nValue = rtl_ustr_compare( aStr1.getStr(), aStr2.getStr()); CPPUNIT_ASSERT_EQUAL_MESSAGE("compare failed, strings are equal.", sal_Int32(0), nValue); @@ -50,8 +50,8 @@ namespace rtl_ustr void compare_003() { - OUString aStr1("Line must differ."); - OUString aStr2("Line foo bar, ok, differ."); + OUString aStr1(u"Line must differ."_ustr); + OUString aStr2(u"Line foo bar, ok, differ."_ustr); sal_Int32 nValue = rtl_ustr_compare( aStr1.getStr(), aStr2.getStr()); CPPUNIT_ASSERT_MESSAGE("compare failed, strings differ.", nValue != 0); @@ -81,8 +81,8 @@ namespace rtl_ustr void compare_002() { - OUString aStr1("Line must be equal."); - OUString aStr2("Line must be equal."); + OUString aStr1(u"Line must be equal."_ustr); + OUString aStr2(u"Line must be equal."_ustr); sal_Int32 nValue = rtl_ustr_compareIgnoreAsciiCase( aStr1.getStr(), aStr2.getStr()); CPPUNIT_ASSERT_EQUAL_MESSAGE("compare failed, strings are equal.", sal_Int32(0), nValue); @@ -90,8 +90,8 @@ namespace rtl_ustr void compare_002_1() { - OUString aStr1("Line must be equal."); - OUString aStr2("LINE MUST BE EQUAL."); + OUString aStr1(u"Line must be equal."_ustr); + OUString aStr2(u"LINE MUST BE EQUAL."_ustr); sal_Int32 nValue = rtl_ustr_compareIgnoreAsciiCase( aStr1.getStr(), aStr2.getStr()); CPPUNIT_ASSERT_EQUAL_MESSAGE("compare failed, strings are equal (if case insensitive).", sal_Int32(0), nValue); @@ -99,8 +99,8 @@ namespace rtl_ustr void compare_003() { - OUString aStr1("Line must differ."); - OUString aStr2("Line foo bar, ok, differ."); + OUString aStr1(u"Line must differ."_ustr); + OUString aStr2(u"Line foo bar, ok, differ."_ustr); sal_Int32 nValue = rtl_ustr_compareIgnoreAsciiCase( aStr1.getStr(), aStr2.getStr()); CPPUNIT_ASSERT_MESSAGE("compare failed, strings differ.", nValue != 0); @@ -127,7 +127,7 @@ namespace rtl_ustr void compare_000_1() { - OUString aStr1("Line must be equal."); + OUString aStr1(u"Line must be equal."_ustr); rtl_ustr_shortenedCompareIgnoreAsciiCase_WithLength( aStr1.getStr(), aStr1.getLength(), nullptr, 0, 1); } void compare_001() @@ -141,8 +141,8 @@ namespace rtl_ustr void compare_002() { - OUString aStr1("Line must be equal."); - OUString aStr2("Line must be equal."); + OUString aStr1(u"Line must be equal."_ustr); + OUString aStr2(u"Line must be equal."_ustr); sal_Int32 nValue = rtl_ustr_shortenedCompareIgnoreAsciiCase_WithLength( aStr1.getStr(), aStr1.getLength(), aStr2.getStr(), aStr2.getLength(), @@ -152,8 +152,8 @@ namespace rtl_ustr void compare_002_1() { - OUString aStr1("Line must be equal."); - OUString aStr2("LINE MUST BE EQUAL."); + OUString aStr1(u"Line must be equal."_ustr); + OUString aStr2(u"LINE MUST BE EQUAL."_ustr); sal_Int32 nValue = rtl_ustr_shortenedCompareIgnoreAsciiCase_WithLength( aStr1.getStr(), aStr1.getLength(), aStr2.getStr(), aStr2.getLength(), @@ -163,8 +163,8 @@ namespace rtl_ustr void compare_003() { - OUString aStr1("Line must differ."); - OUString aStr2("Line foo bar, ok, differ."); + OUString aStr1(u"Line must differ."_ustr); + OUString aStr2(u"Line foo bar, ok, differ."_ustr); sal_Int32 nValue = rtl_ustr_shortenedCompareIgnoreAsciiCase_WithLength( aStr1.getStr(), aStr1.getLength(), aStr2.getStr(), aStr2.getLength(), @@ -174,8 +174,8 @@ namespace rtl_ustr void compare_004() { - OUString aStr1("Line must differ."); - OUString aStr2("Line foo bar, ok, differ."); + OUString aStr1(u"Line must differ."_ustr); + OUString aStr2(u"Line foo bar, ok, differ."_ustr); sal_Int32 nValue = rtl_ustr_shortenedCompareIgnoreAsciiCase_WithLength( aStr1.getStr(), aStr1.getLength(), aStr2.getStr(), aStr2.getLength(), @@ -261,7 +261,7 @@ namespace rtl_ustr void indexOfChar_001() { - OUString aStr1("Line for an indexOfChar."); + OUString aStr1(u"Line for an indexOfChar."_ustr); sal_Int32 nIndex = rtl_ustr_indexOfChar( aStr1.getStr(), 'L' ); CPPUNIT_ASSERT_EQUAL_MESSAGE("index is wrong.", sal_Int32(0), nIndex); @@ -278,7 +278,7 @@ namespace rtl_ustr void indexOfChar_002() { - OUString aStr1("Line for an indexOfChar."); + OUString aStr1(u"Line for an indexOfChar."_ustr); sal_Int32 nIndex = rtl_ustr_indexOfChar( aStr1.getStr(), 'y' ); CPPUNIT_ASSERT_EQUAL_MESSAGE("index is wrong.", sal_Int32(-1), nIndex); @@ -306,7 +306,7 @@ namespace rtl_ustr void lastIndexOfChar_001() { - OUString aStr1("Line for a lastIndexOfChar."); + OUString aStr1(u"Line for a lastIndexOfChar."_ustr); sal_Int32 nIndex = rtl_ustr_lastIndexOfChar( aStr1.getStr(), 'C' ); CPPUNIT_ASSERT_EQUAL_MESSAGE("index is wrong.", sal_Int32(22), nIndex); @@ -323,7 +323,7 @@ namespace rtl_ustr void lastIndexOfChar_002() { - OUString aStr1("Line for a lastIndexOfChar."); + OUString aStr1(u"Line for a lastIndexOfChar."_ustr); sal_Int32 nIndex = rtl_ustr_lastIndexOfChar( aStr1.getStr(), 'y' ); CPPUNIT_ASSERT_EQUAL_MESSAGE("index is wrong.", sal_Int32(-1), nIndex); @@ -344,7 +344,7 @@ namespace rtl_ustr { void indexOfStr_000() { - OUString aStr1("Line for an indexOfStr."); + OUString aStr1(u"Line for an indexOfStr."_ustr); sal_Int32 nIndex = rtl_ustr_indexOfStr( aStr1.getStr(), u"" ); CPPUNIT_ASSERT_EQUAL_MESSAGE("an empty substring is always not findable", sal_Int32(-1), nIndex); @@ -352,9 +352,9 @@ namespace rtl_ustr void indexOfStr_001() { - OUString aStr1("Line for an indexOfStr."); + OUString aStr1(u"Line for an indexOfStr."_ustr); - OUString suSearch("Line"); + OUString suSearch(u"Line"_ustr); sal_Int32 nIndex = rtl_ustr_indexOfStr( aStr1.getStr(), suSearch.getStr() ); CPPUNIT_ASSERT_EQUAL_MESSAGE("index is wrong.", sal_Int32(0), nIndex); @@ -373,8 +373,8 @@ namespace rtl_ustr void indexOfStr_002() { - OUString aStr1("Line for an indexOfStr."); - OUString suSearch("not exist"); + OUString aStr1(u"Line for an indexOfStr."_ustr); + OUString suSearch(u"not exist"_ustr); sal_Int32 nIndex = rtl_ustr_indexOfStr( aStr1.getStr(), suSearch.getStr() ); CPPUNIT_ASSERT_EQUAL_MESSAGE("index is wrong.", sal_Int32(-1), nIndex); @@ -395,7 +395,7 @@ namespace rtl_ustr { void lastIndexOfStr_000() { - OUString aStr1("Line for a lastIndexOfStr."); + OUString aStr1(u"Line for a lastIndexOfStr."_ustr); sal_Int32 nIndex = rtl_ustr_lastIndexOfStr( aStr1.getStr(), u"" ); CPPUNIT_ASSERT_EQUAL_MESSAGE("an empty substring is always not findable", sal_Int32(-1), nIndex); @@ -403,13 +403,13 @@ namespace rtl_ustr void lastIndexOfStr_001() { - OUString aStr1("Line for a lastIndexOfStr."); - OUString aSearchStr("Index"); + OUString aStr1(u"Line for a lastIndexOfStr."_ustr); + OUString aSearchStr(u"Index"_ustr); sal_Int32 nIndex = rtl_ustr_lastIndexOfStr( aStr1.getStr(), aSearchStr.getStr() ); CPPUNIT_ASSERT_EQUAL_MESSAGE("index is wrong.", sal_Int32(15), nIndex); - /* OString */ aSearchStr = OUString("Line"); + /* OString */ aSearchStr = u"Line"_ustr; /* sal_Int32 */ nIndex = rtl_ustr_lastIndexOfStr( aStr1.getStr(), aSearchStr.getStr() ); CPPUNIT_ASSERT_EQUAL_MESSAGE("index is wrong.", sal_Int32(0), nIndex); @@ -420,8 +420,8 @@ namespace rtl_ustr void lastIndexOfStr_002() { - OUString aStr1("Line for a lastIndexOfStr."); - OUString aSearchStr("foo"); + OUString aStr1(u"Line for a lastIndexOfStr."_ustr); + OUString aSearchStr(u"foo"_ustr); sal_Int32 nIndex = rtl_ustr_lastIndexOfStr( aStr1.getStr(), aSearchStr.getStr() ); CPPUNIT_ASSERT_EQUAL_MESSAGE("index is wrong.", sal_Int32(-1), nIndex); @@ -429,8 +429,8 @@ namespace rtl_ustr void lastIndexOfStr_003() { - OUString aStr1("Line for a lastIndexOfStr."); - OUString aSearchStr("O"); + OUString aStr1(u"Line for a lastIndexOfStr."_ustr); + OUString aSearchStr(u"O"_ustr); sal_Int32 nIndex = rtl_ustr_lastIndexOfStr( aStr1.getStr(), aSearchStr.getStr() ); CPPUNIT_ASSERT_EQUAL_MESSAGE("index is wrong.", sal_Int32(20), nIndex); @@ -453,7 +453,7 @@ namespace rtl_ustr void replaceChar_001() { sal_Unicode pStr[] = u"replace char."; - OUString aShouldStr1("ruplacu char."); + OUString aShouldStr1(u"ruplacu char."_ustr); rtl_ustr_replaceChar( pStr, 'e', 'u' ); OUString suStr(pStr); @@ -480,7 +480,7 @@ namespace rtl_ustr void replaceChar_WithLength_001() { sal_Unicode pStr[] = u"replace char."; - OUString aShouldStr1("ruplace char."); + OUString aShouldStr1(u"ruplace char."_ustr); rtl_ustr_replaceChar_WithLength( pStr, 6, 'e', 'u' ); OUString suStr(pStr); @@ -491,7 +491,7 @@ namespace rtl_ustr void replaceChar_WithLength_002() { sal_Unicode pStr[] = u"eeeeeeeeeeeee"; - OUString aShouldStr1("uuuuuueeeeeee"); + OUString aShouldStr1(u"uuuuuueeeeeee"_ustr); rtl_ustr_replaceChar_WithLength( pStr, 6, 'e', 'u' ); OUString suStr(pStr); @@ -515,7 +515,7 @@ namespace rtl_ustr void toAsciiLowerCase_001() { sal_Unicode pStr[] = u"CHANGE THIS TO ASCII LOWER CASE."; - OUString aShouldStr1("change this to ascii lower case."); + OUString aShouldStr1(u"change this to ascii lower case."_ustr); rtl_ustr_toAsciiLowerCase( pStr ); OUString suStr(pStr); @@ -542,7 +542,7 @@ namespace rtl_ustr void toAsciiLowerCase_WithLength_001() { sal_Unicode pStr[] = u"CHANGE THIS TO ASCII LOWER CASE."; - OUString aShouldStr1("change thiS TO ASCII LOWER CASE."); + OUString aShouldStr1(u"change thiS TO ASCII LOWER CASE."_ustr); rtl_ustr_toAsciiLowerCase_WithLength( pStr, 10 ); OUString suStr(pStr); @@ -565,7 +565,7 @@ namespace rtl_ustr void toAsciiUpperCase_001() { sal_Unicode pStr[] = u"change this to ascii upper case."; - OUString aShouldStr1("CHANGE THIS TO ASCII UPPER CASE."); + OUString aShouldStr1(u"CHANGE THIS TO ASCII UPPER CASE."_ustr); rtl_ustr_toAsciiUpperCase( pStr ); OUString suStr(pStr); @@ -592,7 +592,7 @@ namespace rtl_ustr void toAsciiUpperCase_WithLength_001() { sal_Unicode pStr[] = u"change this to ascii lower case."; - OUString aShouldStr1("CHANGE THIs to ascii lower case."); + OUString aShouldStr1(u"CHANGE THIs to ascii lower case."_ustr); rtl_ustr_toAsciiUpperCase_WithLength( pStr, 10 ); OUString suStr(pStr); @@ -718,7 +718,7 @@ namespace rtl_ustr void equal_ascii_shorter() { - OUString refStr("referenceString"); + OUString refStr(u"referenceString"_ustr); char const pAscii[] = "reference"; sal_Int32 value = rtl_ustr_ascii_compare_WithLength(refStr.pData->buffer, refStr.pData->length, pAscii); @@ -727,7 +727,7 @@ namespace rtl_ustr void equal_ascii_shorter_asciiLength() { - OUString refStr("referenceString"); + OUString refStr(u"referenceString"_ustr); char const pAscii[] = "reference"; sal_Int32 value = rtl_ustr_ascii_compare_WithLength(refStr.pData->buffer, rtl_str_getLength(pAscii), pAscii); @@ -736,7 +736,7 @@ namespace rtl_ustr void equal_ref_shorter() { - OUString refStr("reference"); + OUString refStr(u"reference"_ustr); char const pAscii[] = "referenceString"; sal_Int32 value = rtl_ustr_ascii_compare_WithLength(refStr.pData->buffer, refStr.pData->length, pAscii); @@ -745,7 +745,7 @@ namespace rtl_ustr void equal() { - OUString refStr("reference"); + OUString refStr(u"reference"_ustr); char const pAscii[] = "reference"; sal_Int32 value = rtl_ustr_ascii_compare_WithLength(refStr.pData->buffer, refStr.pData->length, pAscii); @@ -754,7 +754,7 @@ namespace rtl_ustr void unequal_reference_bigger() { - OUString refStr("defghi"); + OUString refStr(u"defghi"_ustr); char const pAscii[] = "abc"; sal_Int32 value = rtl_ustr_ascii_compare_WithLength(refStr.pData->buffer, refStr.pData->length, pAscii); @@ -763,7 +763,7 @@ namespace rtl_ustr void unequal_ascii_bigger() { - OUString refStr("abc"); + OUString refStr(u"abc"_ustr); char const pAscii[] = "defghi"; sal_Int32 value = rtl_ustr_ascii_compare_WithLength(refStr.pData->buffer, refStr.pData->length, pAscii); @@ -792,13 +792,13 @@ namespace rtl_ustr void ascii_shortenedCompareIgnoreAsciiCase_WithLength_000_1() { - OUString aStr1("Line must be equal."); + OUString aStr1(u"Line must be equal."_ustr); rtl_ustr_ascii_shortenedCompareIgnoreAsciiCase_WithLength( aStr1.getStr(), aStr1.getLength(), "", 0); // should not GPF } void ascii_shortenedCompareIgnoreAsciiCase_WithLength_000_2() { - OUString aStr1("Line must be equal."); + OUString aStr1(u"Line must be equal."_ustr); OString sStr2 = "Line is shorter."_ostr; rtl_ustr_ascii_shortenedCompareIgnoreAsciiCase_WithLength( aStr1.getStr(), sStr2.getLength(), sStr2.getStr(), 0); // should not GPF @@ -814,7 +814,7 @@ namespace rtl_ustr void ascii_shortenedCompareIgnoreAsciiCase_WithLength_002() { - OUString suStr1("Line must be equal."); + OUString suStr1(u"Line must be equal."_ustr); OString sStr2 = "Line must be equal."_ostr; sal_Int32 nValue = rtl_ustr_ascii_shortenedCompareIgnoreAsciiCase_WithLength( suStr1.getStr(), suStr1.getLength(), sStr2.getStr(), sStr2.getLength()); @@ -823,7 +823,7 @@ namespace rtl_ustr void ascii_shortenedCompareIgnoreAsciiCase_WithLength_003() { - OUString suStr1("Line must differ."); + OUString suStr1(u"Line must differ."_ustr); OString sStr2 = "Line must be differ and longer."_ostr; sal_Int32 nValue = rtl_ustr_ascii_shortenedCompareIgnoreAsciiCase_WithLength( suStr1.getStr(), suStr1.getLength(), sStr2.getStr(), sStr2.getLength()); @@ -854,13 +854,13 @@ namespace rtl_ustr void ascii_compareIgnoreAsciiCase_WithLength_000_1() { - OUString aStr1("Line must be equal."); + OUString aStr1(u"Line must be equal."_ustr); rtl_ustr_ascii_compareIgnoreAsciiCase_WithLength( aStr1.getStr(), 0, ""); // should not GPF } void ascii_compareIgnoreAsciiCase_WithLength_000_2() { - OUString aStr1("Line must be equal."); + OUString aStr1(u"Line must be equal."_ustr); OString sStr2 = "Line is shorter."_ostr; rtl_ustr_ascii_compareIgnoreAsciiCase_WithLength( aStr1.getStr(), sStr2.getLength(), sStr2.getStr()); // should not GPF @@ -876,7 +876,7 @@ namespace rtl_ustr void ascii_compareIgnoreAsciiCase_WithLength_002() { - OUString suStr1("Line must be equal."); + OUString suStr1(u"Line must be equal."_ustr); OString sStr2 = "Line must be equal."_ostr; sal_Int32 nValue = rtl_ustr_ascii_compareIgnoreAsciiCase_WithLength( suStr1.getStr(), suStr1.getLength(), sStr2.getStr()); @@ -885,7 +885,7 @@ namespace rtl_ustr void ascii_compareIgnoreAsciiCase_WithLength_003() { - OUString suStr1("Line must differ."); + OUString suStr1(u"Line must differ."_ustr); OString sStr2 = "Line must be differ and longer."_ostr; sal_Int32 nValue = rtl_ustr_ascii_compareIgnoreAsciiCase_WithLength( suStr1.getStr(), suStr1.getLength(), sStr2.getStr()); @@ -919,7 +919,7 @@ namespace rtl_ustr void ascii_compare_002() { - OUString suStr1("Line must be equal."); + OUString suStr1(u"Line must be equal."_ustr); OString sStr2 = "Line must be equal."_ostr; sal_Int32 nValue = rtl_ustr_ascii_compare( suStr1.getStr(), sStr2.getStr()); @@ -928,7 +928,7 @@ namespace rtl_ustr void ascii_compare_003() { - OUString suStr1("Line must differ."); + OUString suStr1(u"Line must differ."_ustr); OString sStr2 = "Line foo bar, ok, differ."_ostr; sal_Int32 nValue = rtl_ustr_ascii_compare( suStr1.getStr(), sStr2.getStr()); @@ -959,7 +959,7 @@ namespace rtl_ustr void ascii_compareIgnoreAsciiCase_002() { - OUString suStr1("Line must be equal."); + OUString suStr1(u"Line must be equal."_ustr); OString sStr2 = "Line must be equal."_ostr; sal_Int32 nValue = rtl_ustr_ascii_compareIgnoreAsciiCase( suStr1.getStr(), sStr2.getStr()); @@ -968,7 +968,7 @@ namespace rtl_ustr void ascii_compareIgnoreAsciiCase_002_1() { - OUString suStr1("Line must be equal, when ignore case."); + OUString suStr1(u"Line must be equal, when ignore case."_ustr); OString sStr2 = "LINE MUST BE EQUAL, WHEN IGNORE CASE."_ostr; sal_Int32 nValue = rtl_ustr_ascii_compareIgnoreAsciiCase( suStr1.getStr(), sStr2.getStr()); @@ -977,7 +977,7 @@ namespace rtl_ustr void ascii_compareIgnoreAsciiCase_003() { - OUString suStr1("Line must differ."); + OUString suStr1(u"Line must differ."_ustr); OString sStr2 = "Line foo bar, ok, differ."_ostr; sal_Int32 nValue = rtl_ustr_ascii_compareIgnoreAsciiCase( suStr1.getStr(), sStr2.getStr()); @@ -1031,11 +1031,11 @@ namespace rtl_ustr { void getToken_000() { - OUString s("a;b;c"); + OUString s(u"a;b;c"_ustr); // Replace the string in place const sal_Int32 i = rtl_uString_getToken(&s.pData, s.pData, 1, ';', 0); CPPUNIT_ASSERT_EQUAL(sal_Int32(4), i); - CPPUNIT_ASSERT_EQUAL(OUString("b"), s); + CPPUNIT_ASSERT_EQUAL(u"b"_ustr, s); } CPPUNIT_TEST_SUITE(getToken); diff --git a/sal/qa/rtl/oustringbuffer/test_oustringbuffer_assign.cxx b/sal/qa/rtl/oustringbuffer/test_oustringbuffer_assign.cxx index 3c3f436ee5c0..2ddc5aefe253 100644 --- a/sal/qa/rtl/oustringbuffer/test_oustringbuffer_assign.cxx +++ b/sal/qa/rtl/oustringbuffer/test_oustringbuffer_assign.cxx @@ -27,15 +27,15 @@ private: void test() { OUStringBuffer b1; - OUString s1("123456789012345"); + OUString s1(u"123456789012345"_ustr); b1 = s1; CPPUNIT_ASSERT_EQUAL(s1, b1.toString()); CPPUNIT_ASSERT_EQUAL(sal_Int32(16), b1.getCapacity()); - OUString s2("abc"); + OUString s2(u"abc"_ustr); b1 = s2; CPPUNIT_ASSERT_EQUAL(s2, b1.toString()); CPPUNIT_ASSERT_EQUAL(sal_Int32(16), b1.getCapacity()); - OUString s3("1234567890123456"); + OUString s3(u"1234567890123456"_ustr); b1 = s3; CPPUNIT_ASSERT_EQUAL(s3, b1.toString()); CPPUNIT_ASSERT_EQUAL(sal_Int32(32), b1.getCapacity()); diff --git a/sal/qa/rtl/oustringbuffer/test_oustringbuffer_tostring.cxx b/sal/qa/rtl/oustringbuffer/test_oustringbuffer_tostring.cxx index 7de2eb54ac43..766b3c8d247a 100644 --- a/sal/qa/rtl/oustringbuffer/test_oustringbuffer_tostring.cxx +++ b/sal/qa/rtl/oustringbuffer/test_oustringbuffer_tostring.cxx @@ -49,12 +49,12 @@ void test::oustringbuffer::ToString::testEmptyToString() { void test::oustringbuffer::ToString::testToString() { OUStringBuffer sb("test string"); OUString str = sb.toString(); - CPPUNIT_ASSERT_EQUAL( OUString("test string"), str ); + CPPUNIT_ASSERT_EQUAL( u"test string"_ustr, str ); // returned OUString must be independent from sb sb.append( 'a' ); - CPPUNIT_ASSERT_EQUAL( OUString("test string"), str ); + CPPUNIT_ASSERT_EQUAL( u"test string"_ustr, str ); sb.setLength(0); - CPPUNIT_ASSERT_EQUAL( OUString("test string"), str ); + CPPUNIT_ASSERT_EQUAL( u"test string"_ustr, str ); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sal/qa/rtl/process/rtl_Process_Const.h b/sal/qa/rtl/process/rtl_Process_Const.h index aab40ff9a86f..0247a5f528ce 100644 --- a/sal/qa/rtl/process/rtl_Process_Const.h +++ b/sal/qa/rtl/process/rtl_Process_Const.h @@ -26,10 +26,10 @@ extern "C" { #endif -OUString suParam0("-join"); -OUString suParam1("-with"); -OUString suParam2("-child"); -OUString suParam3("-process"); +OUString suParam0(u"-join"_ustr); +OUString suParam1(u"-with"_ustr); +OUString suParam2(u"-child"_ustr); +OUString suParam3(u"-process"_ustr); #ifdef __cplusplus } diff --git a/sal/qa/rtl/strings/test_ostring_concat.cxx b/sal/qa/rtl/strings/test_ostring_concat.cxx index 28453023d18c..86d261dd57e3 100644 --- a/sal/qa/rtl/strings/test_ostring_concat.cxx +++ b/sal/qa/rtl/strings/test_ostring_concat.cxx @@ -161,15 +161,15 @@ void test::ostring::StringConcat::checkAppend() void test::ostring::StringConcat::checkInvalid() { CPPUNIT_ASSERT( !INVALID_CONCAT( OString() + OString())); - CPPUNIT_ASSERT( INVALID_CONCAT( "a"_ostr + OUString( "b" ))); + CPPUNIT_ASSERT( INVALID_CONCAT( "a"_ostr + u"b"_ustr)); CPPUNIT_ASSERT( INVALID_CONCAT( "a"_ostr + OUStringBuffer( "b" ))); CPPUNIT_ASSERT( INVALID_CONCAT( "a"_ostr + OUStringLiteral( u"b" ))); CPPUNIT_ASSERT( INVALID_CONCAT( "a"_ostr + OUString::Concat( u"b" ))); CPPUNIT_ASSERT( INVALID_CONCAT( "a"_ostr + 1 )); rtl_String* rs = nullptr; rtl_uString* rus = nullptr; - CPPUNIT_ASSERT( INVALID_CONCAT( OUString( "b" ) + rs )); - CPPUNIT_ASSERT( INVALID_CONCAT( OUString( "b" ) + rus )); + CPPUNIT_ASSERT( INVALID_CONCAT( u"b"_ustr + rs )); + CPPUNIT_ASSERT( INVALID_CONCAT( u"b"_ustr + rus )); CPPUNIT_ASSERT( INVALID_CONCAT( "a"_ostr + OUString::number( 10 ))); CPPUNIT_ASSERT( INVALID_CONCAT( OString::number( 0 ) + OUString::number( 10 ))); diff --git a/sal/qa/rtl/strings/test_oustring_compare.cxx b/sal/qa/rtl/strings/test_oustring_compare.cxx index 65c29faa6d18..34ba6e32db93 100644 --- a/sal/qa/rtl/strings/test_oustring_compare.cxx +++ b/sal/qa/rtl/strings/test_oustring_compare.cxx @@ -49,16 +49,16 @@ void test::oustring::Compare::equalsIgnoreAsciiCaseAscii() const char* const empty = ""; CPPUNIT_ASSERT(!OUString().equalsIgnoreAsciiCaseAscii(abc)); CPPUNIT_ASSERT(!OUString().equalsIgnoreAsciiCaseAsciiL(abc,3)); - CPPUNIT_ASSERT(!OUString("abc"). + CPPUNIT_ASSERT(!u"abc"_ustr. equalsIgnoreAsciiCaseAscii(empty)); - CPPUNIT_ASSERT(!OUString("abc"). + CPPUNIT_ASSERT(!u"abc"_ustr. equalsIgnoreAsciiCaseAsciiL(empty,0)); - CPPUNIT_ASSERT(OUString("abc"). + CPPUNIT_ASSERT(u"abc"_ustr. equalsIgnoreAsciiCaseAscii(abc)); - CPPUNIT_ASSERT(!OUString("abcd"). + CPPUNIT_ASSERT(!u"abcd"_ustr. equalsIgnoreAsciiCaseAscii(abc)); - CPPUNIT_ASSERT(!OUString("abc"). + CPPUNIT_ASSERT(!u"abc"_ustr. equalsIgnoreAsciiCaseAscii(abcd)); } @@ -66,12 +66,12 @@ void test::oustring::Compare::compareToIgnoreAsciiCase() { CPPUNIT_ASSERT_EQUAL( sal_Int32(0), - OUString("abc").compareToIgnoreAsciiCase(u"ABC")); + u"abc"_ustr.compareToIgnoreAsciiCase(u"ABC")); CPPUNIT_ASSERT( - OUString("ABC").compareToIgnoreAsciiCase(u"abcdef") + u"ABC"_ustr.compareToIgnoreAsciiCase(u"abcdef") < 0); CPPUNIT_ASSERT( - OUString("A").compareToIgnoreAsciiCase(u"_") > 0); + u"A"_ustr.compareToIgnoreAsciiCase(u"_") > 0); } void test::oustring::Compare::compareTo() diff --git a/sal/qa/rtl/strings/test_oustring_concat.cxx b/sal/qa/rtl/strings/test_oustring_concat.cxx index 0aae9c4bc2f3..55f28ac3b0a2 100644 --- a/sal/qa/rtl/strings/test_oustring_concat.cxx +++ b/sal/qa/rtl/strings/test_oustring_concat.cxx @@ -56,57 +56,57 @@ void test::oustring::StringConcat::checkConcat() { // All the extra () are to protect commas against being treated as separators of macro arguments. CPPUNIT_ASSERT_EQUAL( OUString(), OUString(OUString() + OUString())); - CPPUNIT_ASSERT_EQUAL( OUString( "foobar" ), OUString( OUString( "foo" ) + OUString( "bar" ))); - CPPUNIT_ASSERT_EQUAL(( typeid( OUStringConcat< OUString, OUString > )), typeid( OUString( "foo" ) + OUString( "bar" ))); - CPPUNIT_ASSERT_EQUAL( OUString( "foobar" ), OUString( OUString( "foo" ) + "bar" )); - CPPUNIT_ASSERT_EQUAL(( typeid( OUStringConcat< OUString, const char[ 4 ] > )), typeid( OUString( "foo" ) + "bar" )); - CPPUNIT_ASSERT_EQUAL( OUString( "foobarbaz" ), OUString( OUString( "foo" ) + "bar" + "baz" )); - CPPUNIT_ASSERT_EQUAL(( typeid( OUStringConcat< OUStringConcat< OUString, const char[ 4 ] >, const char[ 4 ] > )), typeid( OUString( "foo" ) + "bar" + "baz" )); - CPPUNIT_ASSERT_EQUAL( OUString( "foobar" ), OUString( OUStringBuffer( "foo" ) + "bar" )); + CPPUNIT_ASSERT_EQUAL( u"foobar"_ustr, OUString( u"foo"_ustr + u"bar"_ustr)); + CPPUNIT_ASSERT_EQUAL(( typeid( OUStringConcat< OUString, OUString > )), typeid( u"foo"_ustr + u"bar"_ustr)); + CPPUNIT_ASSERT_EQUAL( u"foobar"_ustr, OUString( u"foo"_ustr + "bar" )); + CPPUNIT_ASSERT_EQUAL(( typeid( OUStringConcat< OUString, const char[ 4 ] > )), typeid( u"foo"_ustr + "bar" )); + CPPUNIT_ASSERT_EQUAL( u"foobarbaz"_ustr, OUString( u"foo"_ustr + "bar" + "baz" )); + CPPUNIT_ASSERT_EQUAL(( typeid( OUStringConcat< OUStringConcat< OUString, const char[ 4 ] >, const char[ 4 ] > )), typeid( u"foo"_ustr + "bar" + "baz" )); + CPPUNIT_ASSERT_EQUAL( u"foobar"_ustr, OUString( OUStringBuffer( "foo" ) + "bar" )); CPPUNIT_ASSERT_EQUAL(( typeid( OUStringConcat< OUStringBuffer, const char[ 4 ] > )), typeid( OUStringBuffer( "foo" ) + "bar" )); - CPPUNIT_ASSERT_EQUAL( OUString( "foobar" ), OUString( OUStringLiteral( u"foo" ) + "bar" )); + CPPUNIT_ASSERT_EQUAL( u"foobar"_ustr, OUString( OUStringLiteral( u"foo" ) + "bar" )); CPPUNIT_ASSERT_EQUAL(( typeid( OUStringConcat< OUStringLiteral<4>, const char[ 4 ] > )), typeid( OUStringLiteral( u"foo" ) + "bar" )); const char d1[] = "xyz"; - CPPUNIT_ASSERT_EQUAL( OUString( "fooxyz" ), OUString( OUString( "foo" ) + d1 )); - CPPUNIT_ASSERT_EQUAL(( typeid( OUStringConcat< OUString, const char[ 4 ] > )), typeid( OUString( "foo" ) + d1 )); + CPPUNIT_ASSERT_EQUAL( u"fooxyz"_ustr, OUString( u"foo"_ustr + d1 )); + CPPUNIT_ASSERT_EQUAL(( typeid( OUStringConcat< OUString, const char[ 4 ] > )), typeid( u"foo"_ustr + d1 )); const sal_Unicode* d2 = u"xyz"; - CPPUNIT_ASSERT_EQUAL( OUString( "fooxyz" ), OUString( OUString( "foo" ) + d2 )); - CPPUNIT_ASSERT_EQUAL(( typeid( OUStringConcat< OUString, const sal_Unicode* > )), typeid( OUString( "foo" ) + d2 )); + CPPUNIT_ASSERT_EQUAL( u"fooxyz"_ustr, OUString( u"foo"_ustr + d2 )); + CPPUNIT_ASSERT_EQUAL(( typeid( OUStringConcat< OUString, const sal_Unicode* > )), typeid( u"foo"_ustr + d2 )); const sal_Unicode d3[] = u"xyz"; - CPPUNIT_ASSERT_EQUAL( OUString( "foobar" ), OUString( OUString::Concat( "foo" ) + "bar" )); + CPPUNIT_ASSERT_EQUAL( u"foobar"_ustr, OUString( OUString::Concat( "foo" ) + "bar" )); CPPUNIT_ASSERT_EQUAL(( typeid( OUStringConcat< OUStringConcat< rtl::OUStringConcatMarker, const char[ 4 ] >, const char[ 4 ] > )), typeid( OUString::Concat( "foo" ) + "bar" )); - CPPUNIT_ASSERT_EQUAL( OUString( "xyzbar" ), OUString( OUString::Concat( d1 ) + "bar" )); + CPPUNIT_ASSERT_EQUAL( u"xyzbar"_ustr, OUString( OUString::Concat( d1 ) + "bar" )); CPPUNIT_ASSERT_EQUAL(( typeid( OUStringConcat< OUStringConcat< rtl::OUStringConcatMarker, const char[ 4 ] >, const char[ 4 ] > )), typeid( OUString::Concat( d1 ) + "bar" )); - CPPUNIT_ASSERT_EQUAL( OUString( "foobar" ), OUString( OUString::Concat( u"foo" ) + "bar" )); + CPPUNIT_ASSERT_EQUAL( u"foobar"_ustr, OUString( OUString::Concat( u"foo" ) + "bar" )); CPPUNIT_ASSERT_EQUAL(( typeid( OUStringConcat< OUStringConcat< rtl::OUStringConcatMarker, const sal_Unicode[ 4 ] >, const char[ 4 ] > )), typeid( OUString::Concat( u"foo" ) + "bar" )); - CPPUNIT_ASSERT_EQUAL( OUString( "xyzbar" ), OUString( OUString::Concat( d2 ) + "bar" )); + CPPUNIT_ASSERT_EQUAL( u"xyzbar"_ustr, OUString( OUString::Concat( d2 ) + "bar" )); CPPUNIT_ASSERT_EQUAL(( typeid( OUStringConcat< OUStringConcat< rtl::OUStringConcatMarker, const sal_Unicode* >, const char[ 4 ] > )), typeid( OUString::Concat( d2 ) + "bar" )); - CPPUNIT_ASSERT_EQUAL( OUString( "xyzbar" ), OUString( OUString::Concat( d3 ) + "bar" )); + CPPUNIT_ASSERT_EQUAL( u"xyzbar"_ustr, OUString( OUString::Concat( d3 ) + "bar" )); CPPUNIT_ASSERT_EQUAL(( typeid( OUStringConcat< OUStringConcat< rtl::OUStringConcatMarker, const sal_Unicode[ 4 ] >, const char[ 4 ] > )), typeid( OUString::Concat( d3 ) + "bar" )); - CPPUNIT_ASSERT_EQUAL( OUString( "num10" ), OUString( OUString( "num" ) + OUString::number( 10 ))); - CPPUNIT_ASSERT_EQUAL(( typeid( OUStringConcat< OUString, StringNumber< sal_Unicode, RTL_USTR_MAX_VALUEOFINT32 > > )), typeid( OUString( "num" ) + OUString::number( 10 ))); - CPPUNIT_ASSERT_EQUAL( OUString( "num10" ), OUString( OUString( "num" ) + OUString::number( 10L ))); - CPPUNIT_ASSERT_EQUAL(( typeid( OUStringConcat< OUString, StringNumber< sal_Unicode, RTL_USTR_MAX_VALUEOFINT64 > > )), typeid( OUString( "num" ) + OUString::number( 10L ))); - CPPUNIT_ASSERT_EQUAL( OUString( "num10" ), OUString( OUString( "num" ) + OUString::number( 10ULL ))); - CPPUNIT_ASSERT_EQUAL(( typeid( OUStringConcat< OUString, StringNumber< sal_Unicode, RTL_USTR_MAX_VALUEOFUINT64 > > )), typeid( OUString( "num" ) + OUString::number( 10ULL ))); - CPPUNIT_ASSERT_EQUAL( OUString( "num10.5" ), OUString( OUString( "num" ) + OUString::number( 10.5f ))); - CPPUNIT_ASSERT_EQUAL(( typeid( OUStringConcat< OUString, OUString > )), typeid( OUString( "num" ) + OUString::number( 10.5f ))); - CPPUNIT_ASSERT_EQUAL( OUString( "num10.5" ), OUString( OUString( "num" ) + OUString::number( 10.5 ))); - CPPUNIT_ASSERT_EQUAL(( typeid( OUStringConcat< OUString, OUString > )), typeid( OUString( "num" ) + OUString::number( 10.5 ))); + CPPUNIT_ASSERT_EQUAL( u"num10"_ustr, OUString( u"num"_ustr + OUString::number( 10 ))); + CPPUNIT_ASSERT_EQUAL(( typeid( OUStringConcat< OUString, StringNumber< sal_Unicode, RTL_USTR_MAX_VALUEOFINT32 > > )), typeid( u"num"_ustr + OUString::number( 10 ))); + CPPUNIT_ASSERT_EQUAL( u"num10"_ustr, OUString( u"num"_ustr + OUString::number( 10L ))); + CPPUNIT_ASSERT_EQUAL(( typeid( OUStringConcat< OUString, StringNumber< sal_Unicode, RTL_USTR_MAX_VALUEOFINT64 > > )), typeid( u"num"_ustr + OUString::number( 10L ))); + CPPUNIT_ASSERT_EQUAL( u"num10"_ustr, OUString( u"num"_ustr + OUString::number( 10ULL ))); + CPPUNIT_ASSERT_EQUAL(( typeid( OUStringConcat< OUString, StringNumber< sal_Unicode, RTL_USTR_MAX_VALUEOFUINT64 > > )), typeid( u"num"_ustr + OUString::number( 10ULL ))); + CPPUNIT_ASSERT_EQUAL( u"num10.5"_ustr, OUString( u"num"_ustr + OUString::number( 10.5f ))); + CPPUNIT_ASSERT_EQUAL(( typeid( OUStringConcat< OUString, OUString > )), typeid( u"num"_ustr + OUString::number( 10.5f ))); + CPPUNIT_ASSERT_EQUAL( u"num10.5"_ustr, OUString( u"num"_ustr + OUString::number( 10.5 ))); + CPPUNIT_ASSERT_EQUAL(( typeid( OUStringConcat< OUString, OUString > )), typeid( u"num"_ustr + OUString::number( 10.5 ))); } void test::oustring::StringConcat::checkConcatAsciiL() { { - OUString s("foo"); + OUString s(u"foo"_ustr); s += ""; - CPPUNIT_ASSERT_EQUAL(OUString("foo"), s); + CPPUNIT_ASSERT_EQUAL(u"foo"_ustr, s); } { - OUString s("foo"); + OUString s(u"foo"_ustr); s += "bar"; - CPPUNIT_ASSERT_EQUAL(OUString("foobar"), s); + CPPUNIT_ASSERT_EQUAL(u"foobar"_ustr, s); } } @@ -154,12 +154,12 @@ void test::oustring::StringConcat::checkEnsureCapacity() void test::oustring::StringConcat::checkAppend() { - OUString str( "foo" ); + OUString str( u"foo"_ustr ); str += OUStringLiteral( u"bar" ) + "baz"; - CPPUNIT_ASSERT_EQUAL( OUString( "foobarbaz" ), str ); + CPPUNIT_ASSERT_EQUAL( u"foobarbaz"_ustr, str ); OUStringBuffer buf( "foo" ); buf.append( OUStringLiteral( u"bar" ) + "baz" ); - CPPUNIT_ASSERT_EQUAL( OUString( "foobarbaz" ), buf.makeStringAndClear()); + CPPUNIT_ASSERT_EQUAL( u"foobarbaz"_ustr, buf.makeStringAndClear()); } #define INVALID_CONCAT( expression ) \ @@ -171,20 +171,20 @@ void test::oustring::StringConcat::checkAppend() void test::oustring::StringConcat::checkInvalid() { CPPUNIT_ASSERT( !INVALID_CONCAT( OUString() + OUString())); - CPPUNIT_ASSERT( INVALID_CONCAT( OUString( "a" ) + "b"_ostr)); - CPPUNIT_ASSERT( INVALID_CONCAT( OUString( "a" ) + OStringBuffer( "b" ))); - CPPUNIT_ASSERT( INVALID_CONCAT( OUString( "a" ) + static_cast<const char*>("b") )); + CPPUNIT_ASSERT( INVALID_CONCAT( u"a"_ustr + "b"_ostr)); + CPPUNIT_ASSERT( INVALID_CONCAT( u"a"_ustr + OStringBuffer( "b" ))); + CPPUNIT_ASSERT( INVALID_CONCAT( u"a"_ustr + static_cast<const char*>("b") )); char d[] = "b"; - CPPUNIT_ASSERT( INVALID_CONCAT( OUString( "a" ) + d )); - CPPUNIT_ASSERT( INVALID_CONCAT( OUString( "a" ) + static_cast<char*>(d) )); - CPPUNIT_ASSERT( INVALID_CONCAT( OUString( "a" ) + OStringLiteral( "b" ))); - CPPUNIT_ASSERT( INVALID_CONCAT( OUString( "a" ) + OString::Concat( "b" ))); - CPPUNIT_ASSERT( INVALID_CONCAT( OUString( "a" ) + 1 )); + CPPUNIT_ASSERT( INVALID_CONCAT( u"a"_ustr + d )); + CPPUNIT_ASSERT( INVALID_CONCAT( u"a"_ustr + static_cast<char*>(d) )); + CPPUNIT_ASSERT( INVALID_CONCAT( u"a"_ustr + OStringLiteral( "b" ))); + CPPUNIT_ASSERT( INVALID_CONCAT( u"a"_ustr + OString::Concat( "b" ))); + CPPUNIT_ASSERT( INVALID_CONCAT( u"a"_ustr + 1 )); rtl_String* rs = nullptr; rtl_uString* rus = nullptr; - CPPUNIT_ASSERT( INVALID_CONCAT( OUString( "b" ) + rs )); - CPPUNIT_ASSERT( INVALID_CONCAT( OUString( "b" ) + rus )); - CPPUNIT_ASSERT( INVALID_CONCAT( OUString( "a" ) + OString::number( 10 ))); + CPPUNIT_ASSERT( INVALID_CONCAT( u"b"_ustr + rs )); + CPPUNIT_ASSERT( INVALID_CONCAT( u"b"_ustr + rus )); + CPPUNIT_ASSERT( INVALID_CONCAT( u"a"_ustr + OString::number( 10 ))); CPPUNIT_ASSERT( INVALID_CONCAT( OUString::number( 0 ) + OString::number( 10 ))); #if 0 diff --git a/sal/qa/rtl/strings/test_oustring_startswith.cxx b/sal/qa/rtl/strings/test_oustring_startswith.cxx index 08bc64bcf5d9..e27310b82461 100644 --- a/sal/qa/rtl/strings/test_oustring_startswith.cxx +++ b/sal/qa/rtl/strings/test_oustring_startswith.cxx @@ -29,9 +29,9 @@ CPPUNIT_TEST_SUITE_REGISTRATION(test::oustring::StartsWith); void test::oustring::StartsWith::startsWith() { - CPPUNIT_ASSERT( OUString( "foobar" ).startsWith( "foo" )); - CPPUNIT_ASSERT( !OUString( "foo" ).startsWith( "foobar" )); - CPPUNIT_ASSERT( !OUString( "foobar" ).startsWith( "oo" )); + CPPUNIT_ASSERT( u"foobar"_ustr.startsWith( "foo" )); + CPPUNIT_ASSERT( !u"foo"_ustr.startsWith( "foobar" )); + CPPUNIT_ASSERT( !u"foobar"_ustr.startsWith( "oo" )); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sal/qa/rtl/strings/test_strings_defaultstringview.cxx b/sal/qa/rtl/strings/test_strings_defaultstringview.cxx index 3e7c5f971599..cbedc3a8e461 100644 --- a/sal/qa/rtl/strings/test_strings_defaultstringview.cxx +++ b/sal/qa/rtl/strings/test_strings_defaultstringview.cxx @@ -34,24 +34,22 @@ class Test : public CppUnit::TestFixture void ustring() { CPPUNIT_ASSERT_EQUAL(OUString(), OUString(std::u16string_view())); - OUString s1("foo"); + OUString s1(u"foo"_ustr); s1 = std::u16string_view(); CPPUNIT_ASSERT_EQUAL(OUString(), s1); - OUString s2("foo"); + OUString s2(u"foo"_ustr); s2 += std::u16string_view(); - CPPUNIT_ASSERT_EQUAL(OUString("foo"), s2); + CPPUNIT_ASSERT_EQUAL(u"foo"_ustr, s2); + CPPUNIT_ASSERT_GREATER(sal_Int32(0), u"foo"_ustr.reverseCompareTo(std::u16string_view())); + CPPUNIT_ASSERT_EQUAL(false, u"foo"_ustr.equalsIgnoreAsciiCase(std::u16string_view())); CPPUNIT_ASSERT_GREATER(sal_Int32(0), - OUString("foo").reverseCompareTo(std::u16string_view())); - CPPUNIT_ASSERT_EQUAL(false, OUString("foo").equalsIgnoreAsciiCase(std::u16string_view())); - CPPUNIT_ASSERT_GREATER(sal_Int32(0), - OUString("foo").compareToIgnoreAsciiCase(std::u16string_view())); - CPPUNIT_ASSERT_EQUAL(true, OUString("foo").match(std::u16string_view())); - CPPUNIT_ASSERT_EQUAL(true, OUString("foo").matchIgnoreAsciiCase(std::u16string_view())); - CPPUNIT_ASSERT_EQUAL(true, OUString("foo").startsWith(std::u16string_view())); - CPPUNIT_ASSERT_EQUAL(true, - OUString("foo").startsWithIgnoreAsciiCase(std::u16string_view())); - CPPUNIT_ASSERT_EQUAL(true, OUString("foo").endsWith(std::u16string_view())); - CPPUNIT_ASSERT_EQUAL(true, OUString("foo").endsWithIgnoreAsciiCase(std::u16string_view())); + u"foo"_ustr.compareToIgnoreAsciiCase(std::u16string_view())); + CPPUNIT_ASSERT_EQUAL(true, u"foo"_ustr.match(std::u16string_view())); + CPPUNIT_ASSERT_EQUAL(true, u"foo"_ustr.matchIgnoreAsciiCase(std::u16string_view())); + CPPUNIT_ASSERT_EQUAL(true, u"foo"_ustr.startsWith(std::u16string_view())); + CPPUNIT_ASSERT_EQUAL(true, u"foo"_ustr.startsWithIgnoreAsciiCase(std::u16string_view())); + CPPUNIT_ASSERT_EQUAL(true, u"foo"_ustr.endsWith(std::u16string_view())); + CPPUNIT_ASSERT_EQUAL(true, u"foo"_ustr.endsWithIgnoreAsciiCase(std::u16string_view())); OUString constexpr foo(u"foo"_ustr); // avoid loplugin:stringconstant, loplugin:stringview CPPUNIT_ASSERT_EQUAL(false, foo == std::u16string_view()); CPPUNIT_ASSERT_EQUAL(true, foo != std::u16string_view()); @@ -65,35 +63,32 @@ class Test : public CppUnit::TestFixture CPPUNIT_ASSERT_EQUAL(true, std::u16string_view() <= foo); CPPUNIT_ASSERT_EQUAL(false, std::u16string_view() > foo); CPPUNIT_ASSERT_EQUAL(false, std::u16string_view() >= foo); - CPPUNIT_ASSERT_EQUAL(sal_Int32(-1), OUString("foo").indexOf(std::u16string_view())); - CPPUNIT_ASSERT_EQUAL(sal_Int32(-1), OUString("foo").lastIndexOf(std::u16string_view())); - CPPUNIT_ASSERT_EQUAL(sal_Int32(-1), OUString("foo").lastIndexOf(std::u16string_view(), 3)); - CPPUNIT_ASSERT_EQUAL( - OUString("foobarfoo"), - OUString("foobarfoo").replaceFirst(std::u16string_view(), std::u16string_view())); - CPPUNIT_ASSERT_EQUAL( - OUString("barfoo"), - OUString("foobarfoo").replaceFirst(std::u16string_view(u"foo"), std::u16string_view())); - CPPUNIT_ASSERT_EQUAL( - OUString("foobarfoo"), - OUString("foobarfoo").replaceFirst(std::u16string_view(), std::u16string_view(u"baz"))); - CPPUNIT_ASSERT_EQUAL(OUString("barfoo"), - OUString("foobarfoo").replaceFirst("foo", std::u16string_view())); - CPPUNIT_ASSERT_EQUAL(OUString("foobarfoo"), - OUString("foobarfoo").replaceFirst(std::u16string_view(), "baz")); + CPPUNIT_ASSERT_EQUAL(sal_Int32(-1), u"foo"_ustr.indexOf(std::u16string_view())); + CPPUNIT_ASSERT_EQUAL(sal_Int32(-1), u"foo"_ustr.lastIndexOf(std::u16string_view())); + CPPUNIT_ASSERT_EQUAL(sal_Int32(-1), u"foo"_ustr.lastIndexOf(std::u16string_view(), 3)); + CPPUNIT_ASSERT_EQUAL(u"foobarfoo"_ustr, u"foobarfoo"_ustr.replaceFirst( + std::u16string_view(), std::u16string_view())); CPPUNIT_ASSERT_EQUAL( - OUString("foobarfoo"), - OUString("foobarfoo").replaceAll(std::u16string_view(), std::u16string_view())); + u"barfoo"_ustr, + u"foobarfoo"_ustr.replaceFirst(std::u16string_view(u"foo"), std::u16string_view())); CPPUNIT_ASSERT_EQUAL( - OUString("bar"), - OUString("foobarfoo").replaceAll(std::u16string_view(u"foo"), std::u16string_view())); + u"foobarfoo"_ustr, + u"foobarfoo"_ustr.replaceFirst(std::u16string_view(), std::u16string_view(u"baz"))); + CPPUNIT_ASSERT_EQUAL(u"barfoo"_ustr, + u"foobarfoo"_ustr.replaceFirst("foo", std::u16string_view())); + CPPUNIT_ASSERT_EQUAL(u"foobarfoo"_ustr, + u"foobarfoo"_ustr.replaceFirst(std::u16string_view(), "baz")); + CPPUNIT_ASSERT_EQUAL(u"foobarfoo"_ustr, u"foobarfoo"_ustr.replaceAll( + std::u16string_view(), std::u16string_view())); + CPPUNIT_ASSERT_EQUAL(u"bar"_ustr, u"foobarfoo"_ustr.replaceAll(std::u16string_view(u"foo"), + std::u16string_view())); CPPUNIT_ASSERT_EQUAL( - OUString("foobarfoo"), - OUString("foobarfoo").replaceAll(std::u16string_view(), std::u16string_view(u"baz"))); - CPPUNIT_ASSERT_EQUAL(OUString("bar"), - OUString("foobarfoo").replaceAll("foo", std::u16string_view())); - CPPUNIT_ASSERT_EQUAL(OUString("foobarfoo"), - OUString("foobarfoo").replaceAll(std::u16string_view(), "baz")); + u"foobarfoo"_ustr, + u"foobarfoo"_ustr.replaceAll(std::u16string_view(), std::u16string_view(u"baz"))); + CPPUNIT_ASSERT_EQUAL(u"bar"_ustr, + u"foobarfoo"_ustr.replaceAll("foo", std::u16string_view())); + CPPUNIT_ASSERT_EQUAL(u"foobarfoo"_ustr, + u"foobarfoo"_ustr.replaceAll(std::u16string_view(), "baz")); CPPUNIT_ASSERT_EQUAL(OUString(), OUString::createFromAscii(std::string_view())); } @@ -101,7 +96,7 @@ class Test : public CppUnit::TestFixture { OUStringBuffer b("foo"); b.append(std::u16string_view()); - CPPUNIT_ASSERT_EQUAL(OUString("foo"), b.toString()); + CPPUNIT_ASSERT_EQUAL(u"foo"_ustr, b.toString()); } CPPUNIT_TEST_SUITE(Test); diff --git a/sal/qa/rtl/strings/test_strings_replace.cxx b/sal/qa/rtl/strings/test_strings_replace.cxx index ddc60acda9d7..5417a5fa9288 100644 --- a/sal/qa/rtl/strings/test_strings_replace.cxx +++ b/sal/qa/rtl/strings/test_strings_replace.cxx @@ -19,12 +19,12 @@ namespace { OUString s_empty; -OUString s_bar("bar"); -OUString s_bars("bars"); -OUString s_foo("foo"); -OUString s_other("other"); -OUString s_xa("xa"); -OUString s_xx("xx"); +OUString s_bar(u"bar"_ustr); +OUString s_bars(u"bars"_ustr); +OUString s_foo(u"foo"_ustr); +OUString s_other(u"other"_ustr); +OUString s_xa(u"xa"_ustr); +OUString s_xx(u"xx"_ustr); class Test: public CppUnit::TestFixture { private: @@ -111,128 +111,128 @@ void Test::stringReplaceAll() { void Test::ustringReplaceFirst() { CPPUNIT_ASSERT_EQUAL( - OUString("otherbarfoo"), - OUString("foobarfoo").replaceFirst(s_foo, s_other)); + u"otherbarfoo"_ustr, + u"foobarfoo"_ustr.replaceFirst(s_foo, s_other)); CPPUNIT_ASSERT_EQUAL( - OUString("foobarfoo"), - OUString("foobarfoo").replaceFirst(s_bars, s_other)); + u"foobarfoo"_ustr, + u"foobarfoo"_ustr.replaceFirst(s_bars, s_other)); { sal_Int32 n = 0; CPPUNIT_ASSERT_EQUAL( - OUString("otherbarfoo"), - OUString("foobarfoo").replaceFirst(s_foo, s_other, &n)); + u"otherbarfoo"_ustr, + u"foobarfoo"_ustr.replaceFirst(s_foo, s_other, &n)); CPPUNIT_ASSERT_EQUAL(sal_Int32(0), n); } { sal_Int32 n = 1; CPPUNIT_ASSERT_EQUAL( - OUString("foobarother"), - OUString("foobarfoo").replaceFirst(s_foo, s_other, &n)); + u"foobarother"_ustr, + u"foobarfoo"_ustr.replaceFirst(s_foo, s_other, &n)); CPPUNIT_ASSERT_EQUAL(sal_Int32(6), n); } { sal_Int32 n = 4; CPPUNIT_ASSERT_EQUAL( - OUString("foobarfoo"), - OUString("foobarfoo").replaceFirst(s_bar, s_other, &n)); + u"foobarfoo"_ustr, + u"foobarfoo"_ustr.replaceFirst(s_bar, s_other, &n)); CPPUNIT_ASSERT_EQUAL(sal_Int32(-1), n); } } void Test::ustringReplaceFirstAsciiL() { CPPUNIT_ASSERT_EQUAL( - OUString("otherbarfoo"), - OUString("foobarfoo").replaceFirst("foo", s_other)); + u"otherbarfoo"_ustr, + u"foobarfoo"_ustr.replaceFirst("foo", s_other)); CPPUNIT_ASSERT_EQUAL( - OUString("foobarfoo"), - OUString("foobarfoo").replaceFirst("bars", s_other)); + u"foobarfoo"_ustr, + u"foobarfoo"_ustr.replaceFirst("bars", s_other)); { sal_Int32 n = 0; CPPUNIT_ASSERT_EQUAL( - OUString("otherbarfoo"), - OUString("foobarfoo").replaceFirst("foo", s_other, &n)); + u"otherbarfoo"_ustr, + u"foobarfoo"_ustr.replaceFirst("foo", s_other, &n)); CPPUNIT_ASSERT_EQUAL(sal_Int32(0), n); } { sal_Int32 n = 1; CPPUNIT_ASSERT_EQUAL( - OUString("foobarother"), - OUString("foobarfoo").replaceFirst("foo", s_other, &n)); + u"foobarother"_ustr, + u"foobarfoo"_ustr.replaceFirst("foo", s_other, &n)); CPPUNIT_ASSERT_EQUAL(sal_Int32(6), n); } { sal_Int32 n = 4; CPPUNIT_ASSERT_EQUAL( - OUString("foobarfoo"), - OUString("foobarfoo").replaceFirst("bar", s_other, &n)); + u"foobarfoo"_ustr, + u"foobarfoo"_ustr.replaceFirst("bar", s_other, &n)); CPPUNIT_ASSERT_EQUAL(sal_Int32(-1), n); } CPPUNIT_ASSERT_EQUAL( - OUString(), OUString("xa").replaceFirst("xa", s_empty)); + OUString(), u"xa"_ustr.replaceFirst("xa", s_empty)); } void Test::ustringReplaceFirstToAsciiL() { CPPUNIT_ASSERT_EQUAL( - OUString("otherbarfoo"), - OUString("foobarfoo").replaceFirst(s_foo, "other")); + u"otherbarfoo"_ustr, + u"foobarfoo"_ustr.replaceFirst(s_foo, "other")); CPPUNIT_ASSERT_EQUAL( - OUString("foobarfoo"), - OUString("foobarfoo").replaceFirst(s_bars, "other")); + u"foobarfoo"_ustr, + u"foobarfoo"_ustr.replaceFirst(s_bars, "other")); { sal_Int32 n = 0; CPPUNIT_ASSERT_EQUAL( - OUString("otherbarfoo"), - OUString("foobarfoo").replaceFirst(s_foo, "other", &n)); + u"otherbarfoo"_ustr, + u"foobarfoo"_ustr.replaceFirst(s_foo, "other", &n)); CPPUNIT_ASSERT_EQUAL(sal_Int32(0), n); } { sal_Int32 n = 1; CPPUNIT_ASSERT_EQUAL( - OUString("foobarother"), - OUString("foobarfoo").replaceFirst(s_foo, "other", &n)); + u"foobarother"_ustr, + u"foobarfoo"_ustr.replaceFirst(s_foo, "other", &n)); CPPUNIT_ASSERT_EQUAL(sal_Int32(6), n); } { sal_Int32 n = 4; CPPUNIT_ASSERT_EQUAL( - OUString("foobarfoo"), - OUString("foobarfoo").replaceFirst(s_bar, "other", &n)); + u"foobarfoo"_ustr, + u"foobarfoo"_ustr.replaceFirst(s_bar, "other", &n)); CPPUNIT_ASSERT_EQUAL(sal_Int32(-1), n); } CPPUNIT_ASSERT_EQUAL( - OUString(), OUString("xa").replaceFirst(s_xa, "")); + OUString(), u"xa"_ustr.replaceFirst(s_xa, "")); } void Test::ustringReplaceFirstAsciiLAsciiL() { CPPUNIT_ASSERT_EQUAL( - OUString("otherbarfoo"), - (OUString("foobarfoo"). + u"otherbarfoo"_ustr, + (u"foobarfoo"_ustr. replaceFirst("foo", "other"))); CPPUNIT_ASSERT_EQUAL( - OUString("foobarfoo"), - (OUString("foobarfoo"). + u"foobarfoo"_ustr, + (u"foobarfoo"_ustr. replaceFirst("bars", "other"))); { sal_Int32 n = 0; CPPUNIT_ASSERT_EQUAL( - OUString("otherbarfoo"), - (OUString("foobarfoo"). + u"otherbarfoo"_ustr, + (u"foobarfoo"_ustr. replaceFirst("foo", "other", &n))); CPPUNIT_ASSERT_EQUAL(sal_Int32(0), n); } @@ -240,8 +240,8 @@ void Test::ustringReplaceFirstAsciiLAsciiL() { { sal_Int32 n = 1; CPPUNIT_ASSERT_EQUAL( - OUString("foobarother"), - (OUString("foobarfoo"). + u"foobarother"_ustr, + (u"foobarfoo"_ustr. replaceFirst("foo", "other", &n))); CPPUNIT_ASSERT_EQUAL(sal_Int32(6), n); } @@ -249,85 +249,85 @@ void Test::ustringReplaceFirstAsciiLAsciiL() { { sal_Int32 n = 4; CPPUNIT_ASSERT_EQUAL( - OUString("foobarfoo"), - (OUString("foobarfoo"). + u"foobarfoo"_ustr, + (u"foobarfoo"_ustr. replaceFirst("bar", "other", &n))); CPPUNIT_ASSERT_EQUAL(sal_Int32(-1), n); } CPPUNIT_ASSERT_EQUAL( - OUString(), OUString("xa").replaceFirst("xa", "")); + OUString(), u"xa"_ustr.replaceFirst("xa", "")); } void Test::ustringReplaceAll() { CPPUNIT_ASSERT_EQUAL( - OUString("otherbarother"), - OUString("foobarfoo").replaceAll(s_foo, s_other)); + u"otherbarother"_ustr, + u"foobarfoo"_ustr.replaceAll(s_foo, s_other)); CPPUNIT_ASSERT_EQUAL( - OUString("foobarfoo"), - OUString("foobarfoo").replaceAll(s_bars, s_other)); + u"foobarfoo"_ustr, + u"foobarfoo"_ustr.replaceAll(s_bars, s_other)); CPPUNIT_ASSERT_EQUAL( - OUString("xxa"), - OUString("xaa").replaceAll(s_xa, s_xx)); + u"xxa"_ustr, + u"xaa"_ustr.replaceAll(s_xa, s_xx)); CPPUNIT_ASSERT_EQUAL( - OUString("foobarbaz"), OUString("foobarfoo").replaceAll(u"foo", u"baz", 1)); + u"foobarbaz"_ustr, u"foobarfoo"_ustr.replaceAll(u"foo", u"baz", 1)); } void Test::ustringReplaceAllAsciiL() { CPPUNIT_ASSERT_EQUAL( - OUString("otherbarother"), - OUString("foobarfoo").replaceAll("foo", s_other)); + u"otherbarother"_ustr, + u"foobarfoo"_ustr.replaceAll("foo", s_other)); CPPUNIT_ASSERT_EQUAL( - OUString("foobarfoo"), - OUString("foobarfoo").replaceAll("bars", s_other)); + u"foobarfoo"_ustr, + u"foobarfoo"_ustr.replaceAll("bars", s_other)); CPPUNIT_ASSERT_EQUAL( - OUString("xxa"), - OUString("xaa").replaceAll("xa", s_xx)); + u"xxa"_ustr, + u"xaa"_ustr.replaceAll("xa", s_xx)); CPPUNIT_ASSERT_EQUAL( - OUString(), OUString("xa").replaceAll("xa", s_empty)); + OUString(), u"xa"_ustr.replaceAll("xa", s_empty)); } void Test::ustringReplaceAllToAsciiL() { CPPUNIT_ASSERT_EQUAL( - OUString("otherbarother"), - OUString("foobarfoo").replaceAll(s_foo, "other")); + u"otherbarother"_ustr, + u"foobarfoo"_ustr.replaceAll(s_foo, "other")); CPPUNIT_ASSERT_EQUAL( - OUString("foobarfoo"), - OUString("foobarfoo").replaceAll(s_bars, "other")); + u"foobarfoo"_ustr, + u"foobarfoo"_ustr.replaceAll(s_bars, "other")); CPPUNIT_ASSERT_EQUAL( - OUString("xxa"), - OUString("xaa").replaceAll(s_xa, "xx")); + u"xxa"_ustr, + u"xaa"_ustr.replaceAll(s_xa, "xx")); CPPUNIT_ASSERT_EQUAL( - OUString(), OUString("xa").replaceAll(s_xa, "")); + OUString(), u"xa"_ustr.replaceAll(s_xa, "")); } void Test::ustringReplaceAllAsciiLAsciiL() { CPPUNIT_ASSERT_EQUAL( - OUString("otherbarother"), - (OUString("foobarfoo"). + u"otherbarother"_ustr, + (u"foobarfoo"_ustr. replaceAll("foo", "other"))); CPPUNIT_ASSERT_EQUAL( - OUString("foobarfoo"), - (OUString("foobarfoo"). + u"foobarfoo"_ustr, + (u"foobarfoo"_ustr. replaceAll("bars", "other"))); CPPUNIT_ASSERT_EQUAL( - OUString("xxa"), - (OUString("xaa"). + u"xxa"_ustr, + (u"xaa"_ustr. replaceAll("xa", "xx"))); CPPUNIT_ASSERT_EQUAL( - OUString(), OUString("xa").replaceAll("xa", "")); + OUString(), u"xa"_ustr.replaceAll("xa", "")); } } diff --git a/sal/rtl/bootstrap.cxx b/sal/rtl/bootstrap.cxx index a0fa9f3c2000..754003e7a0e8 100644 --- a/sal/rtl/bootstrap.cxx +++ b/sal/rtl/bootstrap.cxx @@ -107,7 +107,7 @@ OUString recursivelyExpandMacros( if (requestStack->file == requestFile && requestStack->key == requestKey) { - return "***RECURSION DETECTED***"; + return u"***RECURSION DETECTED***"_ustr; } } ExpandRequestLink link = { requestStack, requestFile, requestKey }; @@ -232,7 +232,7 @@ static OUString getIniFileName(bool overriding) { : OUString("vnd.sun.star.pathname:/instdir/program/sofficerc"); resolvePathnameUrl(&fileName); #else - if (!overriding && getFromCommandLineArgs("INIFILENAME", &fileName)) + if (!overriding && getFromCommandLineArgs(u"INIFILENAME"_ustr, &fileName)) { resolvePathnameUrl(&fileName); } @@ -245,7 +245,7 @@ static OUString getIniFileName(bool overriding) { fileName = fileName.replaceAt(i, fileName.getLength() - i, u"fundamental.override.ini"); } else { // get rid of a potential executable extension - OUString progExt = ".bin"; + OUString progExt = u".bin"_ustr; if (fileName.getLength() > progExt.getLength() && o3tl::equalsIgnoreAsciiCase(fileName.subView(fileName.getLength() - progExt.getLength()), progExt)) { @@ -445,7 +445,7 @@ struct FundamentalIniData OUString uri; ini = (get_static_bootstrap_handle()->getValue( - "URE_BOOTSTRAP", &uri.pData, nullptr, LookupMode::NORMAL, false, + u"URE_BOOTSTRAP"_ustr, &uri.pData, nullptr, LookupMode::NORMAL, false, nullptr) && resolvePathnameUrl(&uri)) ? rtl_bootstrap_args_open(uri.pData) : nullptr; @@ -486,14 +486,14 @@ bool Bootstrap_Impl::getValue( if (key == "_OS") { rtl_uString_assign( - value, OUString(RTL_OS).pData); + value, (u"" RTL_OS ""_ustr).pData); return true; } if (key == "_ARCH") { rtl_uString_assign( - value, OUString(RTL_ARCH).pData); + value, (u"" RTL_ARCH ""_ustr).pData); return true; } @@ -501,9 +501,7 @@ bool Bootstrap_Impl::getValue( { rtl_uString_assign( value, - (OUString( - SAL_STRINGIFY(CPPU_ENV)). - pData)); + (u"" SAL_STRINGIFY(CPPU_ENV) ""_ustr).pData); return true; } |