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

@ -514,10 +514,18 @@ void DefinesStreamProxy::ExtractParametersFromDefineUsage(const ParserLine& line
if (c == ',') if (c == ',')
{ {
parameterValues.emplace_back(currentValue.str()); if (parenthesisDepth > 0)
currentValue.clear(); {
currentValue.str(std::string()); valueHasStarted = true;
valueHasStarted = false; currentValue << c;
}
else
{
parameterValues.emplace_back(currentValue.str());
currentValue.clear();
currentValue.str(std::string());
valueHasStarted = false;
}
} }
else if(c == '(') else if(c == '(')
{ {

View File

@ -705,6 +705,23 @@ namespace test::parsing::impl::defines_stream_proxy
REQUIRE(proxy.Eof()); 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]") TEST_CASE("DefinesStreamProxy: Ensure defines can go over multiple lines", "[parsing][parsingstream]")
{ {
const std::vector<std::string> lines const std::vector<std::string> lines