Add unit tests for expected behaviour for DefinesStreamProxy

This commit is contained in:
Jan 2023-12-11 23:18:00 +01:00
parent 6ca9485b55
commit b7022291a8
No known key found for this signature in database
GPG Key ID: 44B581F78FF5C57C

View File

@ -596,4 +596,50 @@ namespace test::parsing::impl::defines_stream_proxy
REQUIRE(proxy.Eof()); REQUIRE(proxy.Eof());
} }
TEST_CASE("DefinesStreamProxy: Macro definition can span multiple lines when used with backslash", "[parsing][parsingstream]")
{
const std::vector<std::string> lines{
"#define testMacro( \\",
" a, \\",
" b, \\",
" c) a + b - c",
"testMacro(1, 2, 3)",
};
MockParserLineStream mockStream(lines);
DefinesStreamProxy proxy(&mockStream);
ExpectLine(&proxy, 1, "");
ExpectLine(&proxy, 2, "");
ExpectLine(&proxy, 3, "");
ExpectLine(&proxy, 4, "");
ExpectLine(&proxy, 5, "1 + 2 - 3");
REQUIRE(proxy.Eof());
}
TEST_CASE("DefinesStreamProxy: Macro usages can span multiple lines if they have args", "[parsing][parsingstream]")
{
const std::vector<std::string> lines{
"#define testMacro(a, b, c) Hello a, this is b. Lets meet at c!",
"testMacro(",
"Peter,",
"Anna,",
"the cinema",
")",
};
MockParserLineStream mockStream(lines);
DefinesStreamProxy proxy(&mockStream);
ExpectLine(&proxy, 1, "");
ExpectLine(&proxy, 2, "");
ExpectLine(&proxy, 3, "");
ExpectLine(&proxy, 4, "");
ExpectLine(&proxy, 5, "");
ExpectLine(&proxy, 6, "Hello Peter, this is Anna. Lets meet at the cinema!");
REQUIRE(proxy.Eof());
}
} // namespace test::parsing::impl::defines_stream_proxy } // namespace test::parsing::impl::defines_stream_proxy