From: Francis Dupont Date: Wed, 11 Apr 2018 12:57:52 +0000 (+0200) Subject: [5495] Added comments in get config tests (4, 6, d2, ca) X-Git-Tag: ha_checkpoint3~1^2 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=6240cdb6490a6db0ab658e0ffb4a214aca8eff28;p=thirdparty%2Fkea.git [5495] Added comments in get config tests (4, 6, d2, ca) --- diff --git a/src/bin/agent/tests/get_config_unittest.cc b/src/bin/agent/tests/get_config_unittest.cc index f20343c606..aff503bea6 100644 --- a/src/bin/agent/tests/get_config_unittest.cc +++ b/src/bin/agent/tests/get_config_unittest.cc @@ -257,16 +257,22 @@ TEST_F(CtrlAgentGetCfgTest, simple) { prettyPrint(unparsed, std::cerr, 0, 4); std::cerr << "\n"; } else { + // get the expected config using the agent syntax parser ElementPtr jsond; ASSERT_NO_THROW(jsond = parseAGENT(expected, true)); + // get the expected config using the generic JSON syntax parser ElementPtr jsonj; ASSERT_NO_THROW(jsonj = parseJSON(expected)); + // the generic JSON parser does not handle comments EXPECT_TRUE(isEquivalent(jsond, moveComments(jsonj))); + // replace the path by its actual value ConstElementPtr ca; ASSERT_NO_THROW(ca = jsonj->get("Control-agent")); ASSERT_TRUE(ca); pathReplacer(ca); + // check that unparsed and updated expected values match EXPECT_TRUE(isEquivalent(unparsed, jsonj)); + // check on pretty prints too std::string current = prettyPrint(unparsed, 0, 4); std::string expected2 = prettyPrint(jsonj, 0, 4); EXPECT_EQ(expected2, current); diff --git a/src/bin/d2/tests/get_config_unittest.cc b/src/bin/d2/tests/get_config_unittest.cc index 008af6b7e7..06643f54f4 100644 --- a/src/bin/d2/tests/get_config_unittest.cc +++ b/src/bin/d2/tests/get_config_unittest.cc @@ -240,12 +240,17 @@ TEST_F(D2GetConfigTest, sample1) { prettyPrint(unparsed, std::cerr, 0, 4); std::cerr << "\n"; } else { + // get the expected config using the d2 syntax parser ElementPtr jsond; ASSERT_NO_THROW(jsond = parseDHCPDDNS(expected, true)); + // get the expected config using the generic JSON syntax parser ElementPtr jsonj; ASSERT_NO_THROW(jsonj = parseJSON(expected)); + // the generic JSON parser does not handle comments EXPECT_TRUE(isEquivalent(jsond, moveComments(jsonj))); + // check that unparsed and expected values match EXPECT_TRUE(isEquivalent(unparsed, jsonj)); + // check on pretty prints too std::string current = prettyPrint(unparsed, 0, 4) + "\n"; EXPECT_EQ(expected, current); if (expected != current) { diff --git a/src/bin/dhcp4/tests/get_config_unittest.cc.skel b/src/bin/dhcp4/tests/get_config_unittest.cc.skel index 4a0242c7d6..03cf51f32a 100644 --- a/src/bin/dhcp4/tests/get_config_unittest.cc.skel +++ b/src/bin/dhcp4/tests/get_config_unittest.cc.skel @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Internet Systems Consortium, Inc. ("ISC") +// Copyright (C) 2017-2018 Internet Systems Consortium, Inc. ("ISC") // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -318,12 +318,17 @@ TEST_P(Dhcp4GetConfigTest, run) { ASSERT_NO_THROW(outputFormatted(dhcp->str())); } else { expected = UNPARSED_CONFIGS[config_counter]; + // get the expected config using the dhcpv4 syntax parser ElementPtr jsond; ASSERT_NO_THROW(jsond = parseDHCP4(expected, true)); ElementPtr jsonj; + // get the expected config using the generic JSON syntax parser ASSERT_NO_THROW(jsonj = parseJSON(expected)); - EXPECT_TRUE(isEquivalent(dhcp, jsonj)); + // the generic JSON parser does not handle comments EXPECT_TRUE(isEquivalent(jsond, moveComments(jsonj))); + // check that unparsed and expected values match + EXPECT_TRUE(isEquivalent(dhcp, jsonj)); + // check on pretty prints too std::string current = prettyPrint(dhcp, 4, 4) + "\n"; EXPECT_EQ(expected, current); if (expected != current) { diff --git a/src/bin/dhcp6/tests/get_config_unittest.cc.skel b/src/bin/dhcp6/tests/get_config_unittest.cc.skel index 50c71cd53d..a66ef09a41 100644 --- a/src/bin/dhcp6/tests/get_config_unittest.cc.skel +++ b/src/bin/dhcp6/tests/get_config_unittest.cc.skel @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Internet Systems Consortium, Inc. ("ISC") +// Copyright (C) 2017-2018 Internet Systems Consortium, Inc. ("ISC") // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -322,12 +322,17 @@ TEST_P(Dhcp6GetConfigTest, run) { ASSERT_NO_THROW(outputFormatted(dhcp->str())); } else { expected = UNPARSED_CONFIGS[config_counter]; + // get the expected config using the dhcpv6 syntax parser ElementPtr jsond; ASSERT_NO_THROW(jsond = parseDHCP6(expected, true)); + // get the expected config using the generic JSON syntax parser ElementPtr jsonj; ASSERT_NO_THROW(jsonj = parseJSON(expected)); - EXPECT_TRUE(isEquivalent(dhcp, jsonj)); + // the generic JSON parser does not handle comments EXPECT_TRUE(isEquivalent(jsond, moveComments(jsonj))); + // check that unparsed and expected values match + EXPECT_TRUE(isEquivalent(dhcp, jsonj)); + // check on pretty prints too std::string current = prettyPrint(dhcp, 4, 4) + "\n"; EXPECT_EQ(expected, current); if (expected != current) {