Fix TestFileParser to support empty strings

Previously empty strings would be replaced with the token name, e.g. "string" in this case.
This commit is contained in:
Alex Beregszaszi
2020-11-04 17:49:23 +00:00
parent 39f6286e9f
commit f2a51bcf38
2 changed files with 2 additions and 4 deletions
+2 -2
View File
@@ -503,9 +503,9 @@ void TestFileParser::Scanner::scanNextToken()
return TokenDesc{Token::Identifier, _literal};
};
auto selectToken = [this](Token _token, std::string const& _literal = "") -> TokenDesc {
auto selectToken = [this](Token _token, std::optional<std::string> _literal = std::nullopt) -> TokenDesc {
advance();
return make_pair(_token, !_literal.empty() ? _literal : formatToken(_token));
return make_pair(_token, _literal.has_value() ? *_literal : formatToken(_token));
};
TokenDesc token = make_pair(Token::Unknown, "");
-2
View File
@@ -120,8 +120,6 @@ private:
std::string m_line;
std::string::const_iterator m_char;
std::string m_currentLiteral;
TokenDesc m_currentToken;
};