mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2025-04-19 07:42:54 +00:00
Fix comment removing defines proxy not properly removing multiple comments per line
This commit is contained in:
parent
782b05a60b
commit
8e7cd0140c
@ -29,6 +29,7 @@ ParserLine CommentRemovingStreamProxy::NextLine()
|
||||
if (c == '*' && i + 1 < line.m_line.size() && line.m_line[i + 1] == '/')
|
||||
{
|
||||
line.m_line.erase(multiLineCommentStart, i + 2 - multiLineCommentStart);
|
||||
i = multiLineCommentStart - 1;
|
||||
multiLineCommentStart = 0;
|
||||
m_inside_multi_line_comment = false;
|
||||
}
|
||||
|
@ -223,4 +223,30 @@ namespace test::parsing::impl::comment_removing_stream_proxy
|
||||
|
||||
REQUIRE(proxy.Eof());
|
||||
}
|
||||
|
||||
TEST_CASE("CommentRemovingStreamProxy: Can have multiple comment blocks in one line", "[parsing][parsingstream]")
|
||||
{
|
||||
const std::vector<std::string> lines
|
||||
{
|
||||
"Hello/* lovely*/ world and/* beautiful*/ universe",
|
||||
"Hello/* lovely*/ world// and beautiful universe",
|
||||
};
|
||||
|
||||
MockParserLineStream mockStream(lines);
|
||||
CommentRemovingStreamProxy proxy(&mockStream);
|
||||
|
||||
{
|
||||
auto line = proxy.NextLine();
|
||||
REQUIRE(line.m_line_number == 1);
|
||||
REQUIRE(line.m_line == "Hello world and universe");
|
||||
}
|
||||
|
||||
{
|
||||
auto line = proxy.NextLine();
|
||||
REQUIRE(line.m_line_number == 2);
|
||||
REQUIRE(line.m_line == "Hello world");
|
||||
}
|
||||
|
||||
REQUIRE(proxy.Eof());
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user