Fix defines proxy not being able to process parameters with underscores

This commit is contained in:
Jan 2021-12-01 23:19:20 +01:00
parent 17e7926442
commit f5ed7880b0
2 changed files with 18 additions and 1 deletions

View File

@ -70,7 +70,7 @@ void DefinesStreamProxy::Define::IdentifyParameters(const std::vector<std::strin
for (auto i = 0u; i < m_value.size(); i++) for (auto i = 0u; i < m_value.size(); i++)
{ {
const auto c = m_value[i]; const auto c = m_value[i];
if (!isalnum(c)) if (!isalnum(c) && c != '_')
{ {
if (inWord) if (inWord)
{ {

View File

@ -471,6 +471,23 @@ namespace test::parsing::impl::defines_stream_proxy
REQUIRE(proxy.Eof()); REQUIRE(proxy.Eof());
} }
TEST_CASE("DefinesStreamProxy: Ensure can define parameters with underscore", "[parsing][parsingstream]")
{
const std::vector<std::string> lines
{
"#define test(test_parameter) this is test_parameter",
"Apparently test(a very cool text);"
};
MockParserLineStream mockStream(lines);
DefinesStreamProxy proxy(&mockStream);
ExpectLine(&proxy, 1, "");
ExpectLine(&proxy, 2, "Apparently this is a very cool text;");
REQUIRE(proxy.Eof());
}
TEST_CASE("DefinesStreamProxy: Ensure simple if is working with truthy value", "[parsing][parsingstream]") TEST_CASE("DefinesStreamProxy: Ensure simple if is working with truthy value", "[parsing][parsingstream]")
{ {
const std::vector<std::string> lines const std::vector<std::string> lines