test: Various micro optimizations: Replaced std::string() with std::string(). Use std::string::clear() instead of s = and prefer std::string::empty() instead of (s == ) for checking a string is empty.

This commit is contained in:
Martin Ettl 2018-01-05 22:03:49 +01:00
parent d6dae27803
commit 53fbfc9fdb
3 changed files with 7 additions and 7 deletions

View File

@ -308,7 +308,7 @@ private:
ASSERT_EQUALS(1714631779, MathLib::toLongNumber("'\\U0001f34c'"));
{
// some unit-testing for a utility function
ASSERT_EQUALS(0, MathLib::characterLiteralToLongNumber(std::string("")));
ASSERT_EQUALS(0, MathLib::characterLiteralToLongNumber(std::string()));
ASSERT_EQUALS(32, MathLib::characterLiteralToLongNumber(std::string(" ")));
ASSERT_EQUALS(538976288, MathLib::characterLiteralToLongNumber(std::string(" ")));
ASSERT_THROW(MathLib::characterLiteralToLongNumber(std::string("\\u")), InternalError);
@ -700,7 +700,7 @@ private:
value = "garbage";
ASSERT_EQUALS(false, MathLib::isValidIntegerSuffix(value.begin(), value.end()));
value = "";
value.clear();
ASSERT_EQUALS(false, MathLib::isValidIntegerSuffix(value.begin(), value.end()));
value = "llu ";

View File

@ -2596,7 +2596,7 @@ private:
" if ((ret = alloc(&p)) != 0) return;\n"
" free(p);\n"
"}");
ASSERT_EQUALS(std::string(""), errout.str());
ASSERT_EQUALS(std::string(), errout.str());
}

View File

@ -1361,7 +1361,7 @@ private:
" if (pDocSh && !getCellRangesForAddress(nFlags)) ;\n"
"}");
ASSERT(db && errout.str() == "");
ASSERT(db && errout.str().empty());
if (db) {
const Scope *scope = db->findScopeByName("getFormula1");
@ -1377,7 +1377,7 @@ private:
" if (pDocSh && !getCellRangesForAddress(nFlags)) ;\n"
"}");
ASSERT(db && errout.str() == "");
ASSERT(db && errout.str().empty());
if (db) {
const Scope *scope = db->findScopeByName("getFormula1");
@ -1397,7 +1397,7 @@ private:
" if (pDocSh && !getCellRangesForAddress(nFlags)) ;\n"
"}");
ASSERT(db && errout.str() == "");
ASSERT(db && errout.str().empty());
if (db) {
const Scope *scope = db->findScopeByName("getFormula1");
@ -1414,7 +1414,7 @@ private:
"extern void f5() { };\n"
"void f6() { }");
ASSERT(db && errout.str() == "");
ASSERT(db && errout.str().empty());
if (db) {
const Token *f = Token::findsimplematch(tokenizer.tokens(), "f1");