/// @param txt text to be compared
/// @param parser_type bison parser type to be instantiated
/// @param compare whether to compare the output with legacy JSON parser
-void testParser(const std::string& txt, Parser6Context::ParserType parser_type) {
- ElementPtr reference_json;
+void testParser(const std::string& txt, Parser6Context::ParserType parser_type,
+ bool compare = true) {
ConstElementPtr test_json;
- ASSERT_NO_THROW(reference_json = Element::fromJSON(txt, true));
ASSERT_NO_THROW({
try {
Parser6Context ctx;
});
+ if (!compare) {
+ return;
+ }
+
// Now compare if both representations are the same.
+ ElementPtr reference_json;
+ ASSERT_NO_THROW(reference_json = Element::fromJSON(txt, true));
compareJSON(reference_json, test_json);
}
" \"interface\": \"eth0\""
" } ],"
"\"valid-lifetime\": 4000 } }";
- testParser2(txt, Parser6Context::PARSER_DHCP6);
+ testParser(txt, Parser6Context::PARSER_DHCP6, false);
}
// Tests if bash (#) comments can start anywhere, not just in the first line.
" \"interface\": \"eth0\""
" } ],"
"\"valid-lifetime\": 4000 } }";
- testParser2(txt, Parser6Context::PARSER_DHCP6);
+ testParser(txt, Parser6Context::PARSER_DHCP6, false);
}
// Tests if multi-line C style comments are handled correctly.
" \"interface\": \"eth0\""
" } ],"
"\"valid-lifetime\": 4000 } }";
- testParser2(txt, Parser6Context::PARSER_DHCP6);
+ testParser(txt, Parser6Context::PARSER_DHCP6, false);
}
/// @brief Loads specified example config file
EXPECT_NO_THROW(reference_json = Element::fromJSONFile(decommented, true));
+ // remove the temporary file
+ EXPECT_NO_THROW(::remove(decommented.c_str()));
+
EXPECT_NO_THROW(
try {
Parser6Context ctx;
ASSERT_TRUE(test_json);
compareJSON(reference_json, test_json);
-
- unlink(decommented.c_str());
}
// This test loads all available existing files. Each config is loaded