Restructure StreamProxies to use common basis for matching directives

This commit is contained in:
Jan
2021-02-14 10:26:18 +01:00
parent e277de4517
commit efa39a8ac3
10 changed files with 244 additions and 115 deletions

View File

@ -294,4 +294,48 @@ namespace test::parsing::impl::defines_stream_proxy
REQUIRE(proxy.Eof());
}
TEST_CASE("DefinesStreamProxy: Ensure defines in disabled block are ignored", "[parsing][parsingstream]")
{
const std::vector<std::string> lines
{
"#ifdef LOLO",
"#define hello world",
"#endif",
"hello"
};
MockParserLineStream mockStream(lines);
DefinesStreamProxy proxy(&mockStream);
ExpectLine(&proxy, 1, "");
ExpectLine(&proxy, 2, "");
ExpectLine(&proxy, 3, "");
ExpectLine(&proxy, 4, "hello");
REQUIRE(proxy.Eof());
}
TEST_CASE("DefinesStreamProxy: Ensure undefs in disabled block are ignored", "[parsing][parsingstream]")
{
const std::vector<std::string> lines
{
"#define hello world",
"#ifdef LOLO",
"#undef hello",
"#endif",
"hello"
};
MockParserLineStream mockStream(lines);
DefinesStreamProxy proxy(&mockStream);
ExpectLine(&proxy, 1, "");
ExpectLine(&proxy, 2, "");
ExpectLine(&proxy, 3, "");
ExpectLine(&proxy, 4, "");
ExpectLine(&proxy, 5, "world");
REQUIRE(proxy.Eof());
}
}

View File

@ -13,7 +13,6 @@ class MockLexer final : public ILexer<TokenType>
static_assert(std::is_base_of<IParserValue, TokenType>::value);
std::vector<TokenType> m_tokens;
//std::vector<HeaderParserValue> m_tokens;
TokenType m_eof;
int m_pop_count;
@ -58,4 +57,9 @@ public:
{
return m_pop_count;
}
_NODISCARD ParserLine GetLineForPos(const TokenPos& pos) const override
{
return ParserLine();
}
};