diff options
author | Norbert Thiebaud <nthiebaud@gmail.com> | 2012-06-01 06:17:05 -0500 |
---|---|---|
committer | Norbert Thiebaud <nthiebaud@gmail.com> | 2012-06-01 06:30:57 -0500 |
commit | 55bfc3b62a0ffd38bec682b03856505cf8cb7172 (patch) | |
tree | ed285b9fa4a66f3621f1e7fea7e6b72fec931c93 /sal/qa/rtl | |
parent | 08dedb5ea1acf78ab355c5444ab68a3dc522b1a4 (diff) |
targeted string re-work
Change-Id: I6b23bd671c3c090a7c3b60d5301c59da5f9354d5
Diffstat (limited to 'sal/qa/rtl')
-rw-r--r-- | sal/qa/rtl/bootstrap/rtl_Bootstrap.cxx | 122 |
1 files changed, 58 insertions, 64 deletions
diff --git a/sal/qa/rtl/bootstrap/rtl_Bootstrap.cxx b/sal/qa/rtl/bootstrap/rtl_Bootstrap.cxx index 38ffcd44026f..8f6c929c23bc 100644 --- a/sal/qa/rtl/bootstrap/rtl_Bootstrap.cxx +++ b/sal/qa/rtl/bootstrap/rtl_Bootstrap.cxx @@ -94,7 +94,7 @@ inline ::rtl::OUString getModulePath( void ) suDirPath = suDirPath.copy( 0, suDirPath.lastIndexOf('/') ); suDirPath = suDirPath.copy( 0, suDirPath.lastIndexOf('/') + 1); - suDirPath += rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("bin")); + suDirPath += rtl::OUString("bin"); return suDirPath; } @@ -121,12 +121,12 @@ inline rtl::OUString t_getSourcePath(rtl::OString const& _sFilename) { rtl::OUString aDirURL(getExecutableDirectory()); - aDirURL += OUString(RTL_CONSTASCII_USTRINGPARAM("/")); + aDirURL += OUString("/"); aDirURL += OUString::createFromAscii( _sFilename.getStr() ); #if defined(WNT) - aDirURL += rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(".ini")); + aDirURL += rtl::OUString(".ini"); #else - aDirURL += rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("rc")); + aDirURL += rtl::OUString("rc"); #endif return aDirURL; } @@ -211,7 +211,7 @@ namespace rtl_Bootstrap { Bootstrap aBootstrap; rtl::OUString suValue; - rtl::OUString suValuename (RTL_CONSTASCII_USTRINGPARAM("SOLAR_JAVA")); + rtl::OUString suValuename ("SOLAR_JAVA"); //aBootstrap.getFrom( suValuename, suValue ); aBootstrap.getFrom( suValuename, suValue ); sal_Char * pStr = getenv("SOLAR_JAVA"); @@ -223,7 +223,7 @@ namespace rtl_Bootstrap { Bootstrap aBootstrap; rtl::OUString suValue; - rtl::OUString suValuename (RTL_CONSTASCII_USTRINGPARAM("SRC_ROOT")); + rtl::OUString suValuename ("SRC_ROOT"); //aBootstrap.getFrom( suValuename, suValue ); aBootstrap.getFrom( suValuename, suValue ); sal_Char * pStr = getenv("SRC_ROOT"); @@ -244,7 +244,7 @@ namespace rtl_Bootstrap rtl::OUString suIniname = t_getSourcePath(TESTSHL2_INI); Bootstrap aBootstrap( suIniname ); rtl::OUString suGetname; - rtl::OUString suValuename (RTL_CONSTASCII_USTRINGPARAM("INHERITED_VALUE")); + rtl::OUString suValuename ("INHERITED_VALUE"); aBootstrap.getFrom( suValuename, suGetname ); printUString( suGetname ); CPPUNIT_ASSERT_MESSAGE("get the value of a variable in ini file.", suGetname.getLength() != 0 ); @@ -256,8 +256,8 @@ namespace rtl_Bootstrap rtl::OUString suIniname = t_getSourcePath(TESTSHL2_INI); Bootstrap aBootstrap( suIniname ); rtl::OUString suGetname; - rtl::OUString suValuename(RTL_CONSTASCII_USTRINGPARAM("MY_VALUE")); - rtl::OUString myDefault(RTL_CONSTASCII_USTRINGPARAM("2")); + rtl::OUString suValuename("MY_VALUE"); + rtl::OUString myDefault("2"); aBootstrap.getFrom( suValuename, suGetname, myDefault ); CPPUNIT_ASSERT_MESSAGE("getFrom use default.", suGetname.compareTo( myDefault ) == 0 ); } @@ -274,26 +274,26 @@ namespace rtl_Bootstrap aBootstrap.getIniName( suGetIniName ); printUString(suGetIniName, "Current bootstrap file"); - sal_Int32 nIndex = suGetIniName.indexOf(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("pseudo"))); + sal_Int32 nIndex = suGetIniName.indexOf(rtl::OUString("pseudo")); CPPUNIT_ASSERT_MESSAGE("ini name must have 'pseudo' in name.", nIndex > 0); rtl::OUString suValue; - rtl::OUString suKeyName(RTL_CONSTASCII_USTRINGPARAM("FILE")); + rtl::OUString suKeyName("FILE"); aBootstrap.getFrom( suKeyName, suValue ); printUString( suValue ); - sal_Int32 nCompare = suValue.compareTo( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("pseudo file")) ); + sal_Int32 nCompare = suValue.compareTo( rtl::OUString("pseudo file") ); CPPUNIT_ASSERT_MESSAGE("<Bootstrap('pseudo')>.getFrom('FILE', ...) result is unexpected.", nCompare == 0); } void getFrom_004_1() { // get the same key out of the default context - rtl::OUString suKeyName(RTL_CONSTASCII_USTRINGPARAM("FILE")); + rtl::OUString suKeyName("FILE"); rtl::OUString suGetValue; Bootstrap::get( suKeyName, suGetValue ); printUString( suGetValue ); - CPPUNIT_ASSERT_MESSAGE("Bootstrap::get('FILE', ...)", suGetValue.compareTo( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("testshl2 file")) ) == 0 ); + CPPUNIT_ASSERT_MESSAGE("Bootstrap::get('FILE', ...)", suGetValue.compareTo( rtl::OUString("testshl2 file") ) == 0 ); } /** helper function: return the child process's ret value( typedef sal_uInt32 oslProcessExitCode;) @@ -304,14 +304,14 @@ namespace rtl_Bootstrap rtl::OUString suCWD = getModulePath(); oslProcess hProcess = NULL; rtl::OUString suFileURL = suCWD; - suFileURL += rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/")) + rtl::OUString::createFromAscii(process_name) ; + suFileURL += rtl::OUString("/") + rtl::OUString::createFromAscii(process_name) ; #if defined(WNT) - suFileURL += rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(".exe")); + suFileURL += rtl::OUString(".exe"); #endif const int nParameterCount = 3; rtl_uString* pParameters[ nParameterCount ]; OUString suFlag( OUString::createFromAscii(flag) ); - OUString suEnv1( RTL_CONSTASCII_USTRINGPARAM("-env:UNO_SERVICES=service.rdb") ); + OUString suEnv1( "-env:UNO_SERVICES=service.rdb" ); OUString suIniname = t_getSourcePath("rtl"); printUString( suIniname, "rtl path:"); @@ -446,7 +446,7 @@ namespace rtl_Bootstrap Bootstrap::setIniFilename( suIniname ); rtl::OUString suGetname; - rtl::OUString suValuename(RTL_CONSTASCII_USTRINGPARAM("INHERITED_VALUE")); + rtl::OUString suValuename("INHERITED_VALUE"); Bootstrap::get( suValuename, suGetname ); printUString( suGetname ); CPPUNIT_ASSERT_MESSAGE("setIniFilename and get value of the argument.", suGetname.getLength() != 0 ); @@ -486,7 +486,7 @@ namespace rtl_Bootstrap CPPUNIT_ASSERT_MESSAGE("getHandle return NULL!", bsHandle != 0); rtl::OUString suValue; - rtl::OUString suKeyName(RTL_CONSTASCII_USTRINGPARAM("PSEUDOFILE")); + rtl::OUString suKeyName("PSEUDOFILE"); rtl_bootstrap_get_from_handle(bsHandle, suKeyName.pData, &suValue.pData, NULL); printUString( suValue); @@ -516,8 +516,8 @@ namespace rtl_Bootstrap //in ini fle, INHERITED_VALUE=inherited_value rtl::OUString suIniname = t_getSourcePath(TESTSHL2_INI); Bootstrap aBootstrap( suIniname); - rtl::OUString suName(RTL_CONSTASCII_USTRINGPARAM("INHERITED_VALUE")); - rtl::OUString suValue(RTL_CONSTASCII_USTRINGPARAM("ok")); + rtl::OUString suName("INHERITED_VALUE"); + rtl::OUString suValue("ok"); // set to another value Bootstrap::set( suName, suValue ); rtl::OUString suGetValue; @@ -528,13 +528,13 @@ namespace rtl_Bootstrap { rtl::OUString suIniname = t_getSourcePath(TESTSHL2_INI); Bootstrap myBootstrap( suIniname); - rtl::OUString suName(RTL_CONSTASCII_USTRINGPARAM("INHERITED_VALUE")); + rtl::OUString suName("INHERITED_VALUE"); rtl::OUString suGetOrientValue; Bootstrap::get( suName, suGetOrientValue); // ?? INHERITED_VALUE = ok now, which is set in set_001 printUString( suGetOrientValue ); - rtl::OUString suValue(RTL_CONSTASCII_USTRINGPARAM( TESTSHL2_INI )); + rtl::OUString suValue( TESTSHL2_INI ); // set to another value Bootstrap::set( suName, suValue ); rtl::OUString suGetValue; @@ -562,10 +562,10 @@ namespace rtl_Bootstrap { rtl::OUString suIniname = t_getSourcePath(TESTSHL2_INI); Bootstrap aBootstrap( suIniname); - rtl::OUString suMacro(RTL_CONSTASCII_USTRINGPARAM("$MYVAR/expand1")); + rtl::OUString suMacro("$MYVAR/expand1"); //expandMacro now aBootstrap.expandMacrosFrom( suMacro ); - rtl::OUString suExpectedMacro(RTL_CONSTASCII_USTRINGPARAM("src680_test/expand1")); + rtl::OUString suExpectedMacro("src680_test/expand1"); CPPUNIT_ASSERT_MESSAGE("expandMacrosFrom failed.", suMacro.compareTo(suExpectedMacro) == 0 ); } @@ -583,26 +583,26 @@ namespace rtl_Bootstrap t_print("inifile is:"); printUString( suIniname ); Bootstrap aBootstrap( suIniname) ; - rtl::OUString suMacro(RTL_CONSTASCII_USTRINGPARAM("${")); //rtlrc:Bootstrap:RTLVALUE}"); + rtl::OUString suMacro("${"); //rtlrc:Bootstrap:RTLVALUE}"); - rtl::OUString aDirURL(RTL_CONSTASCII_USTRINGPARAM("$ORIGIN")); - aDirURL += OUString(RTL_CONSTASCII_USTRINGPARAM("/")); - aDirURL += OUString(RTL_CONSTASCII_USTRINGPARAM("rtl")); + rtl::OUString aDirURL("$ORIGIN"); + aDirURL += OUString("/"); + aDirURL += OUString("rtl"); #if defined(WNT) - aDirURL += rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(".ini")); + aDirURL += rtl::OUString(".ini"); #else - aDirURL += rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("rc")); + aDirURL += rtl::OUString("rc"); #endif suMacro += aDirURL;//t_getSourcePath("rtl"); - suMacro += rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("::RTLVALUE}")); + suMacro += rtl::OUString("::RTLVALUE}"); t_print("created macro is: "); printUString( suMacro ); aBootstrap.expandMacrosFrom( suMacro ); t_print("expanded macro is:"); printUString( suMacro ); - rtl::OUString suExpectedMacro(RTL_CONSTASCII_USTRINGPARAM("qadev17")); + rtl::OUString suExpectedMacro("qadev17"); CPPUNIT_ASSERT_MESSAGE("failed, can't expand '${file:///.../" SAL_CONFIGFILE("rtl") "::RTLVALUE}' to 'qadev17'", suMacro.compareTo(suExpectedMacro) == 0 ); } void expandMacrosFrom_002_1() @@ -614,19 +614,19 @@ namespace rtl_Bootstrap rtl::OUString suMacro; // just a simple test, if this really work. - aBootstrap.getFrom(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("SOFROMVALUE2")), suMacro ); + aBootstrap.getFrom(rtl::OUString("SOFROMVALUE2"), suMacro ); t_print("SOFROMVALUE2:"); printUString( suMacro ); CPPUNIT_ASSERT_MESSAGE("'SOFROMVALUE2' seems to do not exist.", suMacro.getLength() > 0 ); - aBootstrap.getFrom(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("SOFROMVALUE")), suMacro ); + aBootstrap.getFrom(rtl::OUString("SOFROMVALUE"), suMacro ); t_print("SOFROMVALUE:"); printUString( suMacro ); //expandMacro now // seems to be, that getFrom() already expand the string - rtl::OUString suExpectedMacro(RTL_CONSTASCII_USTRINGPARAM("src680_qadev")); + rtl::OUString suExpectedMacro("src680_qadev"); CPPUNIT_ASSERT_MESSAGE("failed, can't expand '${" SAL_CONFIGFILE("rtl") "::SOVALUE}' to 'src680_qadev'", suMacro.compareTo(suExpectedMacro) == 0 ); } void expandMacrosFrom_002_2() @@ -640,7 +640,7 @@ namespace rtl_Bootstrap Bootstrap aBootstrap( suIniname); rtl::OUString suMacro; - aBootstrap.getFrom(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("SOFROMVALUE3")), suMacro ); + aBootstrap.getFrom(rtl::OUString("SOFROMVALUE3"), suMacro ); t_print("SOFROMVALUE3:"); printUString( suMacro ); @@ -659,10 +659,10 @@ namespace rtl_Bootstrap rtl::OUString suIniname = t_getSourcePath(TESTSHL2_INI); Bootstrap aBootstrap( suIniname); rtl::OUString suMacro[4]; - suMacro[0] = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("$SYSUSERCONFIG")); - suMacro[1] = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("$SYSUSERHOME")); - suMacro[2] = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("$SYSBINDIR")); - suMacro[3] = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("$ORIGIN")); + suMacro[0] = rtl::OUString("$SYSUSERCONFIG"); + suMacro[1] = rtl::OUString("$SYSUSERHOME"); + suMacro[2] = rtl::OUString("$SYSBINDIR"); + suMacro[3] = rtl::OUString("$ORIGIN"); for ( int i = 0; i < 4; i++ ) { @@ -676,34 +676,28 @@ namespace rtl_Bootstrap } void testRecursion() { - rtl::OUString t(RTL_CONSTASCII_USTRINGPARAM("$RECURSIVE")); + rtl::OUString t("$RECURSIVE"); Bootstrap(t_getSourcePath(TESTSHL2_INI)).expandMacrosFrom(t); CPPUNIT_ASSERT_MESSAGE( "recursion detection", t == "***RECURSION DETECTED***" ); } void testLink() { - rtl::OUString t(RTL_CONSTASCII_USTRINGPARAM("$LINKED")); + rtl::OUString t("$LINKED"); Bootstrap(t_getSourcePath(TESTSHL2_INI)).expandMacrosFrom(t); CPPUNIT_ASSERT_MESSAGE( "link file", t == "qadev17"); } void testOverride() { - rtl::OUString t1( - RTL_CONSTASCII_USTRINGPARAM( - "${.override:$ORIGIN/" SAL_CONFIGFILE("rtl") ":ORIGIN}")); + rtl::OUString t1( "${.override:$ORIGIN/" SAL_CONFIGFILE("rtl" ":ORIGIN}")); Bootstrap(t_getSourcePath("rtl")).expandMacrosFrom(t1); CPPUNIT_ASSERT_MESSAGE( "override ORIGIN", t1 == "direct" ); - rtl::OUString t2( - RTL_CONSTASCII_USTRINGPARAM( - "${.override:$ORIGIN/" SAL_CONFIGFILE("none") ":MYVAR}")); + rtl::OUString t2( "${.override:$ORIGIN/" SAL_CONFIGFILE("none" ":MYVAR}")); Bootstrap::expandMacros(t2); CPPUNIT_ASSERT_MESSAGE( "override MYVAR", t2 == "src680_test" ); } void testNonexisting() { - rtl::OUString t( - RTL_CONSTASCII_USTRINGPARAM( - "${$ORIGIN/" SAL_CONFIGFILE("none") ":MYVAR}")); + rtl::OUString t( "${$ORIGIN/" SAL_CONFIGFILE("none" ":MYVAR}")); Bootstrap::expandMacros(t); CPPUNIT_ASSERT_MESSAGE( "nonexisting", t == "src680_test" ); } @@ -757,13 +751,13 @@ namespace rtl_Bootstrap { rtl::OUString suIniname = t_getSourcePath(TESTSHL2_INI); Bootstrap aBootstrap( suIniname) ; - rtl::OUString suMacro(RTL_CONSTASCII_USTRINGPARAM("$INHERITED_VALUE/well")); + rtl::OUString suMacro("$INHERITED_VALUE/well"); Bootstrap::expandMacros( suMacro ); - rtl::OUString suName(RTL_CONSTASCII_USTRINGPARAM("INHERITED_VALUE")); + rtl::OUString suName("INHERITED_VALUE"); OUString suGetValue; Bootstrap::get( suName, suGetValue ); - suGetValue += OUString(RTL_CONSTASCII_USTRINGPARAM("/well")); + suGetValue += OUString("/well"); CPPUNIT_ASSERT_MESSAGE("expandMacros failed.", suGetValue.compareTo(suMacro) == 0 ); } @@ -821,9 +815,9 @@ static void create_rtlrc() { rtl::OUString aFileURL(getExecutableDirectory()); #if defined(WNT) - aFileURL += rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/rtl.ini")); + aFileURL += rtl::OUString("/rtl.ini"); #else - aFileURL += rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/rtlrc")); + aFileURL += rtl::OUString("/rtlrc"); #endif rtl::OString sLines; @@ -844,9 +838,9 @@ static void create_testshl2rc() { rtl::OUString aFileURL(getExecutableDirectory()); #if defined(WNT) - aFileURL += rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/testshl2.ini")); + aFileURL += rtl::OUString("/testshl2.ini"); #else - aFileURL += rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/testshl2rc")); + aFileURL += rtl::OUString("/testshl2rc"); #endif rtl::OString sLines; sLines += "[Bootstrap]\n"; @@ -874,7 +868,7 @@ static void create_testshl2rc() removeAndCreateFile( (getExecutableDirectory() + - rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/testshl2-link"))), + rtl::OUString("/testshl2-link")), SAL_CONFIGFILE("rtl")); } @@ -884,9 +878,9 @@ static void create_pseudorc() { rtl::OUString aFileURL(getExecutableDirectory()); #if defined(WNT) - aFileURL += rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/pseudo.ini")); + aFileURL += rtl::OUString("/pseudo.ini"); #else - aFileURL += rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/pseudorc")); + aFileURL += rtl::OUString("/pseudorc"); #endif rtl::OString sLines; sLines += "[Bootstrap]\n"; @@ -901,9 +895,9 @@ void create_bootstrap_processrc() { rtl::OUString aDirURL(getModulePath()); #if defined(WNT) - aDirURL += rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/bootstrap_process.ini")); + aDirURL += rtl::OUString("/bootstrap_process.ini"); #else - aDirURL += rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/bootstrap_processrc")); + aDirURL += rtl::OUString("/bootstrap_processrc"); #endif rtl::OString sLines; sLines += "[Bootstrap]\n"; |