Commit 78659fde authored by Tomek Mrugalski's avatar Tomek Mrugalski 🛰

[5036] Unit-tests cleanup.

parent e1c561b3
...@@ -33,7 +33,6 @@ using namespace std; ...@@ -33,7 +33,6 @@ using namespace std;
%code %code
{ {
#include <dhcp6/parser_context.h> #include <dhcp6/parser_context.h>
} }
...@@ -136,6 +135,26 @@ using namespace std; ...@@ -136,6 +135,26 @@ using namespace std;
DHCP_DDNS "dhcp-ddns" DHCP_DDNS "dhcp-ddns"
/// @todo: Implement proper parsing for those parameters in Dhcp6/dhcp-ddns/*.
/// This should be part of the #5043 ticket. Listing the keywords here for
/// completeness.
// These are tokens defined in Dhcp6/dhcp-ddns/*
// They're not
// ENABLE_UPDATES "enable-updates"
// SERVER_IP "server-ip"
// SENDER_IP "sender-ip"
// SENDER_PORT "sender-port"
// MAX_QUEUE_SIZE "max-queue-size"
// NCR_PROTOCOL "ncr-protocol"
// NCR_FORMAT "ncr-format"
// ALWAYS_INCLUDE_FQDN "always-include-fqdn"
// OVERRDIDE_NO_UPDATE "override-no-update"
// OVERRDIDE_CLIENT_UPDATE "override-client-update"
// REPLACE_CLIENT_NAME "replace-client-name"
// GENERATED_PREFIX "generated-prefix"
// QUALIFYING_SUFFIX "qualifying-suffix"
LOGGING "Logging" LOGGING "Logging"
LOGGERS "loggers" LOGGERS "loggers"
OUTPUT_OPTIONS "output_options" OUTPUT_OPTIONS "output_options"
......
...@@ -254,7 +254,8 @@ void testError(const std::string& txt, ...@@ -254,7 +254,8 @@ void testError(const std::string& txt,
try { try {
Parser6Context ctx; Parser6Context ctx;
ConstElementPtr parsed = ctx.parseString(txt, parser_type); ConstElementPtr parsed = ctx.parseString(txt, parser_type);
FAIL() << "Expected Dhcp6ParseError but nothing was raised"; FAIL() << "Expected Dhcp6ParseError but nothing was raised (expected: "
<< msg << ")";
} }
catch (const Dhcp6ParseError& ex) { catch (const Dhcp6ParseError& ex) {
EXPECT_EQ(msg, ex.what()); EXPECT_EQ(msg, ex.what());
...@@ -277,28 +278,22 @@ TEST(ParserTest, errors) { ...@@ -277,28 +278,22 @@ TEST(ParserTest, errors) {
// comments // comments
testError("# nothing\n", testError("# nothing\n",
Parser6Context::PARSER_JSON, Parser6Context::PARSER_JSON,
"<string>:2.1: syntax error, unexpected end of file, " "<string>:2.1: syntax error, unexpected end of file");
"expecting {");
testError(" #\n", testError(" #\n",
Parser6Context::PARSER_JSON, Parser6Context::PARSER_JSON,
"<string>:2.1: syntax error, unexpected end of file, " "<string>:2.1: syntax error, unexpected end of file");
"expecting {");
testError("// nothing\n", testError("// nothing\n",
Parser6Context::PARSER_JSON, Parser6Context::PARSER_JSON,
"<string>:2.1: syntax error, unexpected end of file, " "<string>:2.1: syntax error, unexpected end of file");
"expecting {");
testError("/* nothing */\n", testError("/* nothing */\n",
Parser6Context::PARSER_JSON, Parser6Context::PARSER_JSON,
"<string>:2.1: syntax error, unexpected end of file, " "<string>:2.1: syntax error, unexpected end of file");
"expecting {");
testError("/* no\nthing */\n", testError("/* no\nthing */\n",
Parser6Context::PARSER_JSON, Parser6Context::PARSER_JSON,
"<string>:3.1: syntax error, unexpected end of file, " "<string>:3.1: syntax error, unexpected end of file");
"expecting {");
testError("/* no\nthing */\n\n", testError("/* no\nthing */\n\n",
Parser6Context::PARSER_JSON, Parser6Context::PARSER_JSON,
"<string>:4.1: syntax error, unexpected end of file, " "<string>:4.1: syntax error, unexpected end of file");
"expecting {");
testError("/* nothing\n", testError("/* nothing\n",
Parser6Context::PARSER_JSON, Parser6Context::PARSER_JSON,
"Comment not closed. (/* in line 1"); "Comment not closed. (/* in line 1");
...@@ -333,15 +328,15 @@ TEST(ParserTest, errors) { ...@@ -333,15 +328,15 @@ TEST(ParserTest, errors) {
// numbers // numbers
testError("123", testError("123",
Parser6Context::PARSER_JSON, Parser6Context::PARSER_DHCP6,
"<string>:1.1-3: syntax error, unexpected integer, " "<string>:1.1-3: syntax error, unexpected integer, "
"expecting {"); "expecting {");
testError("-456", testError("-456",
Parser6Context::PARSER_JSON, Parser6Context::PARSER_DHCP6,
"<string>:1.1-4: syntax error, unexpected integer, " "<string>:1.1-4: syntax error, unexpected integer, "
"expecting {"); "expecting {");
testError("-0001", testError("-0001",
Parser6Context::PARSER_JSON, Parser6Context::PARSER_DHCP6,
"<string>:1.1-5: syntax error, unexpected integer, " "<string>:1.1-5: syntax error, unexpected integer, "
"expecting {"); "expecting {");
testError("1234567890123456789012345678901234567890", testError("1234567890123456789012345678901234567890",
...@@ -350,7 +345,7 @@ TEST(ParserTest, errors) { ...@@ -350,7 +345,7 @@ TEST(ParserTest, errors) {
"1234567890123456789012345678901234567890" "1234567890123456789012345678901234567890"
" to an integer."); " to an integer.");
testError("-3.14e+0", testError("-3.14e+0",
Parser6Context::PARSER_JSON, Parser6Context::PARSER_DHCP6,
"<string>:1.1-8: syntax error, unexpected floating point, " "<string>:1.1-8: syntax error, unexpected floating point, "
"expecting {"); "expecting {");
testError("1e50000", testError("1e50000",
...@@ -360,7 +355,7 @@ TEST(ParserTest, errors) { ...@@ -360,7 +355,7 @@ TEST(ParserTest, errors) {
// strings // strings
testError("\"aabb\"", testError("\"aabb\"",
Parser6Context::PARSER_JSON, Parser6Context::PARSER_DHCP6,
"<string>:1.1-6: syntax error, unexpected constant string, " "<string>:1.1-6: syntax error, unexpected constant string, "
"expecting {"); "expecting {");
testError("{ \"aabb\"err", testError("{ \"aabb\"err",
...@@ -373,7 +368,7 @@ TEST(ParserTest, errors) { ...@@ -373,7 +368,7 @@ TEST(ParserTest, errors) {
Parser6Context::PARSER_JSON, Parser6Context::PARSER_JSON,
"<string>:1.1-6: Invalid control in \"a\n\tb\""); "<string>:1.1-6: Invalid control in \"a\n\tb\"");
testError("\"a\\n\\tb\"", testError("\"a\\n\\tb\"",
Parser6Context::PARSER_JSON, Parser6Context::PARSER_DHCP6,
"<string>:1.1-8: syntax error, unexpected constant string, " "<string>:1.1-8: syntax error, unexpected constant string, "
"expecting {"); "expecting {");
testError("\"a\\x01b\"", testError("\"a\\x01b\"",
...@@ -402,7 +397,7 @@ TEST(ParserTest, errors) { ...@@ -402,7 +397,7 @@ TEST(ParserTest, errors) {
// want a map // want a map
testError("[]\n", testError("[]\n",
Parser6Context::PARSER_JSON, Parser6Context::PARSER_DHCP6,
"<string>:1.1: syntax error, unexpected [, " "<string>:1.1: syntax error, unexpected [, "
"expecting {"); "expecting {");
testError("[]\n", testError("[]\n",
......
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