Skip to content

Commit

Permalink
Add unit tests for expected behaviour for DefinesStreamProxy
Browse files Browse the repository at this point in the history
  • Loading branch information
Laupetin authored and Clang Format committed Dec 22, 2023
1 parent 6ca9485 commit 4eb1cd8
Showing 1 changed file with 46 additions and 0 deletions.
46 changes: 46 additions & 0 deletions test/ParserTests/Parsing/Impl/DefinesStreamProxyTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -596,4 +596,50 @@ namespace test::parsing::impl::defines_stream_proxy

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

0 comments on commit 4eb1cd8

Please sign in to comment.