Commit ec1c8fbb authored by aggsol's avatar aggsol 🙉

test for incomplete sections

parent 6de81ccb
......@@ -143,6 +143,10 @@ void Parser::parseLine(const std::string& line, std::map<int, Section>& sections
{
value += c;
}
else if(std::isspace(c))
{
throw std::runtime_error("Invalid whitespace in section reference");
}
break;
case State::Style:
if(c == '\n' || c == ' ' || c == '\t' || c == '\r')
......@@ -267,6 +271,11 @@ void Parser::parseLine(const std::string& line, std::map<int, Section>& sections
}
}
if(state == State::ReferenceSection)
{
throw std::runtime_error("Invalid section reference");
}
if(addLine == true && m_currSection >= 0)
{
sections[m_currSection].m_lines.push_back(line);
......
......@@ -10,9 +10,20 @@ public:
ParserTest()
: tiny::Unit(__FILE__)
{
tiny::Unit::registerTest(&ParserTest::badref, "badref");
tiny::Unit::registerTest(&ParserTest::classes, "classes");
}
static void badref()
{
bodhi::Parser parser("../test/badreference.adoc");
std::map<int, bodhi::Section> sections;
bool error = parser.parse(sections);
TINY_ASSERT_OK(error);
}
static void classes()
{
bodhi::Parser parser("../test/classes.adoc");
......
[[section-1]]
=== 1
blabliblubb
Turn to <<section-2
[[section-2]]
=== 2
blablibubb kj asd aw p3o0rlkfsd
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment