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:
parent
d6dae27803
commit
53fbfc9fdb
|
@ -308,7 +308,7 @@ private:
|
||||||
ASSERT_EQUALS(1714631779, MathLib::toLongNumber("'\\U0001f34c'"));
|
ASSERT_EQUALS(1714631779, MathLib::toLongNumber("'\\U0001f34c'"));
|
||||||
{
|
{
|
||||||
// some unit-testing for a utility function
|
// 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(32, MathLib::characterLiteralToLongNumber(std::string(" ")));
|
||||||
ASSERT_EQUALS(538976288, MathLib::characterLiteralToLongNumber(std::string(" ")));
|
ASSERT_EQUALS(538976288, MathLib::characterLiteralToLongNumber(std::string(" ")));
|
||||||
ASSERT_THROW(MathLib::characterLiteralToLongNumber(std::string("\\u")), InternalError);
|
ASSERT_THROW(MathLib::characterLiteralToLongNumber(std::string("\\u")), InternalError);
|
||||||
|
@ -700,7 +700,7 @@ private:
|
||||||
value = "garbage";
|
value = "garbage";
|
||||||
ASSERT_EQUALS(false, MathLib::isValidIntegerSuffix(value.begin(), value.end()));
|
ASSERT_EQUALS(false, MathLib::isValidIntegerSuffix(value.begin(), value.end()));
|
||||||
|
|
||||||
value = "";
|
value.clear();
|
||||||
ASSERT_EQUALS(false, MathLib::isValidIntegerSuffix(value.begin(), value.end()));
|
ASSERT_EQUALS(false, MathLib::isValidIntegerSuffix(value.begin(), value.end()));
|
||||||
|
|
||||||
value = "llu ";
|
value = "llu ";
|
||||||
|
|
|
@ -2596,7 +2596,7 @@ private:
|
||||||
" if ((ret = alloc(&p)) != 0) return;\n"
|
" if ((ret = alloc(&p)) != 0) return;\n"
|
||||||
" free(p);\n"
|
" free(p);\n"
|
||||||
"}");
|
"}");
|
||||||
ASSERT_EQUALS(std::string(""), errout.str());
|
ASSERT_EQUALS(std::string(), errout.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1361,7 +1361,7 @@ private:
|
||||||
" if (pDocSh && !getCellRangesForAddress(nFlags)) ;\n"
|
" if (pDocSh && !getCellRangesForAddress(nFlags)) ;\n"
|
||||||
"}");
|
"}");
|
||||||
|
|
||||||
ASSERT(db && errout.str() == "");
|
ASSERT(db && errout.str().empty());
|
||||||
|
|
||||||
if (db) {
|
if (db) {
|
||||||
const Scope *scope = db->findScopeByName("getFormula1");
|
const Scope *scope = db->findScopeByName("getFormula1");
|
||||||
|
@ -1377,7 +1377,7 @@ private:
|
||||||
" if (pDocSh && !getCellRangesForAddress(nFlags)) ;\n"
|
" if (pDocSh && !getCellRangesForAddress(nFlags)) ;\n"
|
||||||
"}");
|
"}");
|
||||||
|
|
||||||
ASSERT(db && errout.str() == "");
|
ASSERT(db && errout.str().empty());
|
||||||
|
|
||||||
if (db) {
|
if (db) {
|
||||||
const Scope *scope = db->findScopeByName("getFormula1");
|
const Scope *scope = db->findScopeByName("getFormula1");
|
||||||
|
@ -1397,7 +1397,7 @@ private:
|
||||||
" if (pDocSh && !getCellRangesForAddress(nFlags)) ;\n"
|
" if (pDocSh && !getCellRangesForAddress(nFlags)) ;\n"
|
||||||
"}");
|
"}");
|
||||||
|
|
||||||
ASSERT(db && errout.str() == "");
|
ASSERT(db && errout.str().empty());
|
||||||
|
|
||||||
if (db) {
|
if (db) {
|
||||||
const Scope *scope = db->findScopeByName("getFormula1");
|
const Scope *scope = db->findScopeByName("getFormula1");
|
||||||
|
@ -1414,7 +1414,7 @@ private:
|
||||||
"extern void f5() { };\n"
|
"extern void f5() { };\n"
|
||||||
"void f6() { }");
|
"void f6() { }");
|
||||||
|
|
||||||
ASSERT(db && errout.str() == "");
|
ASSERT(db && errout.str().empty());
|
||||||
|
|
||||||
if (db) {
|
if (db) {
|
||||||
const Token *f = Token::findsimplematch(tokenizer.tokens(), "f1");
|
const Token *f = Token::findsimplematch(tokenizer.tokens(), "f1");
|
||||||
|
|
Loading…
Reference in New Issue