void arguments();
void substatements();
void empty();
+ void comments();
void unterminated_comment();
void missing_semicolon();
void bad_string();
add(&ParserTests::arguments, "Arguments");
add(&ParserTests::substatements, "Substatements");
add(&ParserTests::empty, "Empty input");
+ add(&ParserTests::comments, "Comments");
add(&ParserTests::unterminated_comment, "Unterminated comment").expect_throw<DataFile::data_error>();
add(&ParserTests::missing_semicolon, "Missing semicolon").expect_throw<DataFile::data_error>();
add(&ParserTests::bad_string, "Bad string").expect_throw<DataFile::data_error>();
EXPECT(!st.valid);
}
+void ParserTests::comments()
+{
+ static const char input[] =
+ "// line comment\n"
+ "a;\n"
+ "/* block\n"
+ "comment */\n"
+ "b;\n"
+ "/* block comment with embedded // double\n"
+ "slash */\n"
+ "c;\n"
+ "// line comment with embedded /* slash star\n"
+ "d;\n";
+
+ IO::Memory mem(input, sizeof(input)-1);
+ DataFile::Parser parser(mem, "-");
+ DataFile::Statement st = parser.parse();
+ EXPECT_EQUAL(st.keyword, "a");
+ st = parser.parse();
+ EXPECT_EQUAL(st.keyword, "b");
+ st = parser.parse();
+ EXPECT_EQUAL(st.keyword, "c");
+ st = parser.parse();
+ EXPECT_EQUAL(st.keyword, "d");
+}
+
void ParserTests::unterminated_comment()
{
static const char input[] =