From 683d6404fedd25fcd61ad55bd54c0a0eae3de44e Mon Sep 17 00:00:00 2001 From: Rye Mutt <rye@alchemyviewer.org> Date: Sun, 27 Sep 2020 03:32:24 -0400 Subject: [PATCH] Fix tests after string_view changes --- indra/newview/tests/llagentaccess_test.cpp | 4 ++-- indra/newview/tests/lldateutil_test.cpp | 19 ++++++++++++------- indra/newview/tests/lllogininstance_test.cpp | 10 +++++----- indra/newview/tests/llsecapi_test.cpp | 4 ++-- .../newview/tests/llsechandler_basic_test.cpp | 6 +++--- indra/newview/tests/llslurl_test.cpp | 14 +++++++------- indra/newview/tests/llviewerhelputil_test.cpp | 4 ++-- indra/newview/tests/llviewernetwork_test.cpp | 12 ++++++------ indra/newview/tests/llworldmap_test.cpp | 2 +- indra/newview/tests/llworldmipmap_test.cpp | 2 +- 10 files changed, 41 insertions(+), 36 deletions(-) diff --git a/indra/newview/tests/llagentaccess_test.cpp b/indra/newview/tests/llagentaccess_test.cpp index 9a8d8bb61fa..a2db5a54f47 100644 --- a/indra/newview/tests/llagentaccess_test.cpp +++ b/indra/newview/tests/llagentaccess_test.cpp @@ -55,12 +55,12 @@ LLControlVariable* LLControlGroup::declareU32(const std::string& name, U32 initi return NULL; } -void LLControlGroup::setU32(const std::string& name, U32 val) +void LLControlGroup::setU32(const std::string_view name, U32 val) { test_preferred_maturity = val; } -U32 LLControlGroup::getU32(const std::string& name) +U32 LLControlGroup::getU32(const std::string_view name) { return test_preferred_maturity; } diff --git a/indra/newview/tests/lldateutil_test.cpp b/indra/newview/tests/lldateutil_test.cpp index 62158d8f669..ad299448c5f 100644 --- a/indra/newview/tests/lldateutil_test.cpp +++ b/indra/newview/tests/lldateutil_test.cpp @@ -38,26 +38,31 @@ // Baked-in return values for getString() -std::map< std::string, std::string > gString; +std::map< std::string, std::string, std::less<> > gString; // Baked-in return values for getCountString() // map of pairs of input xml_desc and integer count typedef std::pair< std::string, int > count_string_t; std::map< count_string_t, std::string > gCountString; -std::string LLTrans::getString(const std::string &xml_desc, const LLStringUtil::format_map_t& args, bool def_string) +std::string LLTrans::getString(const std::string_view xml_desc, const LLStringUtil::format_map_t& args, bool def_string) { - std::string text = gString[xml_desc]; - LLStringUtil::format(text, args); - return text; + auto it = gString.find(xml_desc); + if (it != gString.end()) + { + std::string text = it->second; + LLStringUtil::format(text, args); + return text; + } + return {}; } -std::string LLTrans::getCountString(const std::string& language, const std::string& xml_desc, S32 count) +std::string LLTrans::getCountString(const std::string_view language, const std::string_view xml_desc, S32 count) { count_string_t key(xml_desc, count); if (gCountString.find(key) == gCountString.end()) { - return std::string("Couldn't find ") + xml_desc; + return std::string("Couldn't find ") + std::string(xml_desc); } return gCountString[ count_string_t(xml_desc, count) ]; } diff --git a/indra/newview/tests/lllogininstance_test.cpp b/indra/newview/tests/lllogininstance_test.cpp index 57f2d31eabe..11711a64766 100644 --- a/indra/newview/tests/lllogininstance_test.cpp +++ b/indra/newview/tests/lllogininstance_test.cpp @@ -188,12 +188,12 @@ LLControlGroup gSavedSettings("Global"); LLControlGroup::LLControlGroup(const std::string& name) : LLInstanceTracker<LLControlGroup, std::string>(name){} LLControlGroup::~LLControlGroup() {} -void LLControlGroup::setBOOL(const std::string& name, BOOL val) {} -BOOL LLControlGroup::getBOOL(const std::string& name) { return FALSE; } -F32 LLControlGroup::getF32(const std::string& name) { return 0.0f; } +void LLControlGroup::setBOOL(const std::string_view name, BOOL val) {} +BOOL LLControlGroup::getBOOL(const std::string_view name) { return FALSE; } +F32 LLControlGroup::getF32(const std::string_view name) { return 0.0f; } U32 LLControlGroup::saveToFile(const std::string& filename, BOOL nondefault_only) { return 1; } -void LLControlGroup::setString(const std::string& name, const std::string& val) {} -std::string LLControlGroup::getString(const std::string& name) { return "test_string"; } +void LLControlGroup::setString(const std::string_view name, const std::string& val) {} +std::string LLControlGroup::getString(const std::string_view name) { return "test_string"; } LLControlVariable* LLControlGroup::declareBOOL(const std::string& name, BOOL initial_val, const std::string& comment, LLControlVariable::ePersist persist) { return NULL; } LLControlVariable* LLControlGroup::declareString(const std::string& name, const std::string &initial_val, const std::string& comment, LLControlVariable::ePersist persist) { return NULL; } diff --git a/indra/newview/tests/llsecapi_test.cpp b/indra/newview/tests/llsecapi_test.cpp index caa3016d2e9..d27126ce2d6 100644 --- a/indra/newview/tests/llsecapi_test.cpp +++ b/indra/newview/tests/llsecapi_test.cpp @@ -43,8 +43,8 @@ LLControlVariable* LLControlGroup::declareString(const std::string& name, const std::string& initial_val, const std::string& comment, LLControlVariable::ePersist persist) {return NULL;} -void LLControlGroup::setString(const std::string& name, const std::string& val){} -std::string LLControlGroup::getString(const std::string& name) +void LLControlGroup::setString(const std::string_view name, const std::string& val){} +std::string LLControlGroup::getString(const std::string_view name) { return ""; } diff --git a/indra/newview/tests/llsechandler_basic_test.cpp b/indra/newview/tests/llsechandler_basic_test.cpp index e5d226a2a49..15ca66ee013 100644 --- a/indra/newview/tests/llsechandler_basic_test.cpp +++ b/indra/newview/tests/llsechandler_basic_test.cpp @@ -78,8 +78,8 @@ LLControlVariable* LLControlGroup::declareString(const std::string& name, const std::string& initial_val, const std::string& comment, LLControlVariable::ePersist persist) {return NULL;} -void LLControlGroup::setString(const std::string& name, const std::string& val){} -std::string LLControlGroup::getString(const std::string& name) +void LLControlGroup::setString(const std::string_view name, const std::string& val){} +std::string LLControlGroup::getString(const std::string_view name) { if (name == "FirstName") @@ -90,7 +90,7 @@ std::string LLControlGroup::getString(const std::string& name) } // Stub for --no-verify-ssl-cert -BOOL LLControlGroup::getBOOL(const std::string& name) { return FALSE; } +BOOL LLControlGroup::getBOOL(const std::string_view name) { return FALSE; } LLSD LLCredential::getLoginParams() { diff --git a/indra/newview/tests/llslurl_test.cpp b/indra/newview/tests/llslurl_test.cpp index 6a1b96f75a4..d341f8c0c1c 100644 --- a/indra/newview/tests/llslurl_test.cpp +++ b/indra/newview/tests/llslurl_test.cpp @@ -46,10 +46,10 @@ static const char * const TEST_FILENAME("llslurl_test.xml"); class LLTrans { public: - static std::string getString(const std::string &xml_desc, const LLStringUtil::format_map_t& args, bool def_string = false); + static std::string getString(std::string_view xml_desc, const LLStringUtil::format_map_t& args, bool def_string = false); }; -std::string LLTrans::getString(const std::string &xml_desc, const LLStringUtil::format_map_t& args, bool def_string) +std::string LLTrans::getString(const std::string_view xml_desc, const LLStringUtil::format_map_t& args, bool def_string) { return std::string(); } @@ -58,7 +58,7 @@ std::string LLTrans::getString(const std::string &xml_desc, const LLStringUtil:: // Stub implementation to get the test to compile properly #include "../rlvhandler.h" -const std::string& RlvStrings::getString(const std::string& strStringName) +const std::string& RlvStrings::getString(const std::string_view strStringName) { static const std::string strMissing = "(Missing RLVa string)"; return strMissing; @@ -100,14 +100,14 @@ LLControlVariable* LLControlGroup::declareString(const std::string& name, const std::string& initial_val, const std::string& comment, LLControlVariable::ePersist persist) {return NULL;} -void LLControlGroup::setString(const std::string& name, const std::string& val){} +void LLControlGroup::setString(const std::string_view name, const std::string& val){} std::string gCmdLineLoginURI; std::string gCmdLineGridChoice; std::string gCmdLineHelperURI; std::string gLoginPage; std::string gCurrentGrid; -std::string LLControlGroup::getString(const std::string& name) +std::string LLControlGroup::getString(const std::string_view name) { if (name == "CmdLineGridChoice") return gCmdLineGridChoice; @@ -120,7 +120,7 @@ std::string LLControlGroup::getString(const std::string& name) return ""; } -LLSD LLControlGroup::getLLSD(const std::string& name) +LLSD LLControlGroup::getLLSD(const std::string_view name) { if (name == "CmdLineLoginURI") { @@ -132,7 +132,7 @@ LLSD LLControlGroup::getLLSD(const std::string& name) return LLSD(); } -LLPointer<LLControlVariable> LLControlGroup::getControl(const std::string& name) +LLPointer<LLControlVariable> LLControlGroup::getControl(const std::string_view name) { ctrl_name_table_t::iterator iter = mNameTable.find(name); return iter == mNameTable.end() ? LLPointer<LLControlVariable>() : iter->second; diff --git a/indra/newview/tests/llviewerhelputil_test.cpp b/indra/newview/tests/llviewerhelputil_test.cpp index f6456a28392..d4b6b68d24d 100644 --- a/indra/newview/tests/llviewerhelputil_test.cpp +++ b/indra/newview/tests/llviewerhelputil_test.cpp @@ -53,8 +53,8 @@ LLControlVariable* LLControlGroup::declareString(const std::string& name, const std::string& initial_val, const std::string& comment, LLControlVariable::ePersist persist) {return NULL;} -void LLControlGroup::setString(const std::string& name, const std::string& val){} -std::string LLControlGroup::getString(const std::string& name) +void LLControlGroup::setString(const std::string_view name, const std::string& val){} +std::string LLControlGroup::getString(const std::string_view name) { if (name == "HelpURLFormat") return gHelpURL; diff --git a/indra/newview/tests/llviewernetwork_test.cpp b/indra/newview/tests/llviewernetwork_test.cpp index 9fc9ca01ac8..b46b9ecfc57 100644 --- a/indra/newview/tests/llviewernetwork_test.cpp +++ b/indra/newview/tests/llviewernetwork_test.cpp @@ -45,10 +45,10 @@ static const char * const TEST_FILENAME("llviewernetwork_test.xml"); class LLTrans { public: - static std::string getString(const std::string &xml_desc, const LLStringUtil::format_map_t& args, bool def_string = false); + static std::string getString(const std::string_view xml_desc, const LLStringUtil::format_map_t& args, bool def_string = false); }; -std::string LLTrans::getString(const std::string &xml_desc, const LLStringUtil::format_map_t& args, bool def_string) +std::string LLTrans::getString(const std::string_view xml_desc, const LLStringUtil::format_map_t& args, bool def_string) { std::string grid_label = std::string(); if(xml_desc == "AgniGridLabel") @@ -73,14 +73,14 @@ LLControlVariable* LLControlGroup::declareString(const std::string& name, const std::string& initial_val, const std::string& comment, LLControlVariable::ePersist persist) {return NULL;} -void LLControlGroup::setString(const std::string& name, const std::string& val){} +void LLControlGroup::setString(const std::string_view name, const std::string& val){} std::string gCmdLineLoginURI; std::string gCmdLineGridChoice; std::string gCmdLineHelperURI; std::string gLoginPage; std::string gCurrentGrid; -std::string LLControlGroup::getString(const std::string& name) +std::string LLControlGroup::getString(const std::string_view name) { if (name == "CmdLineGridChoice") return gCmdLineGridChoice; @@ -93,7 +93,7 @@ std::string LLControlGroup::getString(const std::string& name) return ""; } -LLSD LLControlGroup::getLLSD(const std::string& name) +LLSD LLControlGroup::getLLSD(const std::string_view name) { if (name == "CmdLineLoginURI") { @@ -105,7 +105,7 @@ LLSD LLControlGroup::getLLSD(const std::string& name) return LLSD(); } -LLPointer<LLControlVariable> LLControlGroup::getControl(const std::string& name) +LLPointer<LLControlVariable> LLControlGroup::getControl(const std::string_view name) { ctrl_name_table_t::iterator iter = mNameTable.find(name); return iter == mNameTable.end() ? LLPointer<LLControlVariable>() : iter->second; diff --git a/indra/newview/tests/llworldmap_test.cpp b/indra/newview/tests/llworldmap_test.cpp index f1dd8acccf1..c765f83a188 100644 --- a/indra/newview/tests/llworldmap_test.cpp +++ b/indra/newview/tests/llworldmap_test.cpp @@ -66,7 +66,7 @@ void LLWorldMipmap::equalizeBoostLevels() { } LLPointer<LLViewerFetchedTexture> LLWorldMipmap::getObjectsTile(U32 grid_x, U32 grid_y, S32 level, bool load) { return NULL; } // Stub other stuff -std::string LLTrans::getString(const std::string &, const LLStringUtil::format_map_t&, bool def_string) { return std::string("test_trans"); } +std::string LLTrans::getString(const std::string_view, const LLStringUtil::format_map_t&, bool def_string) { return std::string("test_trans"); } void LLUIString::updateResult() const { } void LLUIString::setArg(const std::string& , const std::string& ) { } void LLUIString::assign(const std::string& ) { } diff --git a/indra/newview/tests/llworldmipmap_test.cpp b/indra/newview/tests/llworldmipmap_test.cpp index 142d75bcfd5..cf6cd61262e 100644 --- a/indra/newview/tests/llworldmipmap_test.cpp +++ b/indra/newview/tests/llworldmipmap_test.cpp @@ -48,7 +48,7 @@ LLViewerFetchedTexture* LLViewerTextureManager::getFetchedTextureFromUrl(const s LLControlGroup::LLControlGroup(const std::string& name) : LLInstanceTracker<LLControlGroup, std::string>(name) { } LLControlGroup::~LLControlGroup() { } -std::string LLControlGroup::getString(const std::string& ) { return std::string("test_url"); } +std::string LLControlGroup::getString(const std::string_view) { return std::string("test_url"); } LLControlGroup gSavedSettings("test_settings"); // End Stubbing -- GitLab