diff options
author | Francis Dupont <fdupont@isc.org> | 2016-12-10 11:52:02 +0100 |
---|---|---|
committer | Francis Dupont <fdupont@isc.org> | 2016-12-10 11:52:02 +0100 |
commit | aef276b92fabb9c2e762e99706d0aa6d7b6966bb (patch) | |
tree | a641890ece4958f628be6ed75e664df8e1657743 /src | |
parent | Merge branch 'trac5036' of ssh://git.kea.isc.org/git/kea into trac5036 (diff) | |
download | kea-aef276b92fabb9c2e762e99706d0aa6d7b6966bb.tar.xz kea-aef276b92fabb9c2e762e99706d0aa6d7b6966bb.zip |
[5036] Optional exception display and case sensitive JSON unit tests
Diffstat (limited to 'src')
-rw-r--r-- | src/bin/dhcp6/tests/dhcp6_test_utils.h | 14 | ||||
-rw-r--r-- | src/bin/dhcp6/tests/parser_unittest.cc | 8 |
2 files changed, 18 insertions, 4 deletions
diff --git a/src/bin/dhcp6/tests/dhcp6_test_utils.h b/src/bin/dhcp6/tests/dhcp6_test_utils.h index a790acd39d..95f706d351 100644 --- a/src/bin/dhcp6/tests/dhcp6_test_utils.h +++ b/src/bin/dhcp6/tests/dhcp6_test_utils.h @@ -656,16 +656,19 @@ parseJSON(const std::string& in) /// needed. This format is used by most of the tests. /// /// @param in string to be parsed +/// @param verbose display the exception message when it fails /// @return ElementPtr structure representing parsed JSON inline isc::data::ConstElementPtr -parseDHCP6(const std::string& in) +parseDHCP6(const std::string& in, bool verbose = false) { try { isc::dhcp::Parser6Context ctx; return (ctx.parseString(in, isc::dhcp::Parser6Context::SUBPARSER_DHCP6)); } catch (const std::exception& ex) { - std::cout << "EXCEPTION: " << ex.what() << std::endl; + if (verbose) { + std::cout << "EXCEPTION: " << ex.what() << std::endl; + } throw; } } @@ -675,16 +678,19 @@ parseDHCP6(const std::string& in) /// This function parses specified text as JSON that defines option definitions. /// /// @param in string to be parsed +/// @param verbose display the exception message when it fails /// @return ElementPtr structure representing parsed JSON inline isc::data::ConstElementPtr -parseOPTION_DEF(const std::string& in) +parseOPTION_DEF(const std::string& in, bool verbose = false) { try { isc::dhcp::Parser6Context ctx; return (ctx.parseString(in, isc::dhcp::Parser6Context::PARSER_OPTION_DEF)); } catch (const std::exception& ex) { - std::cout << "EXCEPTION: " << ex.what() << std::endl; + if (verbose) { + std::cout << "EXCEPTION: " << ex.what() << std::endl; + } throw; } } diff --git a/src/bin/dhcp6/tests/parser_unittest.cc b/src/bin/dhcp6/tests/parser_unittest.cc index f1919cd25a..7d9abb8b8d 100644 --- a/src/bin/dhcp6/tests/parser_unittest.cc +++ b/src/bin/dhcp6/tests/parser_unittest.cc @@ -326,6 +326,14 @@ TEST(ParserTest, errors) { Parser6Context::PARSER_JSON, "Can't open include file /foo/bar"); + // case sensitivity + testError("{ \"foo\": True }", + Parser6Context::PARSER_JSON, + "<string>:1.10: Invalid character: T"); + testError("{ \"foo\": NULL }", + Parser6Context::PARSER_JSON, + "<string>:1.10: Invalid character: N"); + // numbers testError("123", Parser6Context::PARSER_DHCP6, |