From 067f1a854ea0d013c4143c029906622e392ddea2 Mon Sep 17 00:00:00 2001 From: Jan Date: Sun, 24 Dec 2023 00:44:27 +0100 Subject: [PATCH] Add unit tests for properly parsing comma in square brackets and curly braces in macro usages --- .../Parsing/Impl/DefinesStreamProxyTests.cpp | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/test/ParserTests/Parsing/Impl/DefinesStreamProxyTests.cpp b/test/ParserTests/Parsing/Impl/DefinesStreamProxyTests.cpp index 495406b6..36b6160e 100644 --- a/test/ParserTests/Parsing/Impl/DefinesStreamProxyTests.cpp +++ b/test/ParserTests/Parsing/Impl/DefinesStreamProxyTests.cpp @@ -697,6 +697,38 @@ namespace test::parsing::impl::defines_stream_proxy REQUIRE(proxy.Eof()); } + TEST_CASE("DefinesStreamProxy: Ensure can use comma in square brackets in parameters values", "[parsing][parsingstream]") + { + const std::vector lines{ + "#define someStuff(param1) Hello param1 World", + "someStuff(A sentence with [brackets and a , character] and stuff)", + }; + + MockParserLineStream mockStream(lines); + DefinesStreamProxy proxy(&mockStream); + + ExpectLine(&proxy, 1, ""); + ExpectLine(&proxy, 2, "Hello A sentence with [brackets and a , character] and stuff World"); + + REQUIRE(proxy.Eof()); + } + + TEST_CASE("DefinesStreamProxy: Ensure can use comma in curly braces in parameters values", "[parsing][parsingstream]") + { + const std::vector lines{ + "#define someStuff(param1) Hello param1 World", + "someStuff(A sentence with {braces and a , character} and stuff)", + }; + + MockParserLineStream mockStream(lines); + DefinesStreamProxy proxy(&mockStream); + + ExpectLine(&proxy, 1, ""); + ExpectLine(&proxy, 2, "Hello A sentence with {braces and a , character} and stuff World"); + + REQUIRE(proxy.Eof()); + } + TEST_CASE("DefinesStreamProxy: Ensure defines can go over multiple lines", "[parsing][parsingstream]") { const std::vector lines{