Make defines stream proxy able to accept comma within parameter values that are in parenthesis

This commit is contained in:
Jan 2021-12-02 22:19:48 +01:00
parent f5ed7880b0
commit 4b7a78100d
2 changed files with 29 additions and 4 deletions

View File

@ -513,12 +513,20 @@ void DefinesStreamProxy::ExtractParametersFromDefineUsage(const ParserLine& line
const auto c = line.m_line[pos];
if (c == ',')
{
if (parenthesisDepth > 0)
{
valueHasStarted = true;
currentValue << c;
}
else
{
parameterValues.emplace_back(currentValue.str());
currentValue.clear();
currentValue.str(std::string());
valueHasStarted = false;
}
}
else if(c == '(')
{
valueHasStarted = true;

View File

@ -705,6 +705,23 @@ namespace test::parsing::impl::defines_stream_proxy
REQUIRE(proxy.Eof());
}
TEST_CASE("DefinesStreamProxy: Ensure can use comma in parenthesis in parameters values", "[parsing][parsingstream]")
{
const std::vector<std::string> lines
{
"#define someStuff(param1) Hello param1 World",
"someStuff(A sentence with (parenthesis and a , character) and stuff)"
};
MockParserLineStream mockStream(lines);
DefinesStreamProxy proxy(&mockStream);
ExpectLine(&proxy, 1, "");
ExpectLine(&proxy, 2, "Hello A sentence with (parenthesis and a , character) and stuff World");
REQUIRE(proxy.Eof());
}
TEST_CASE("DefinesStreamProxy: Ensure defines can go over multiple lines", "[parsing][parsingstream]")
{
const std::vector<std::string> lines