From: Razvan Becheriu Date: Mon, 27 Jul 2020 11:49:12 +0000 (+0300) Subject: [#1265] fixed comments and added asserts X-Git-Tag: Kea-1.7.10~7^2~6 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c85f9765160411768cdd91462d48d553c730205b;p=thirdparty%2Fkea.git [#1265] fixed comments and added asserts --- diff --git a/src/bin/dhcp4/tests/kea_controller_unittest.cc b/src/bin/dhcp4/tests/kea_controller_unittest.cc index d6054e07f9..ea3fcd479b 100644 --- a/src/bin/dhcp4/tests/kea_controller_unittest.cc +++ b/src/bin/dhcp4/tests/kea_controller_unittest.cc @@ -433,6 +433,7 @@ TEST_F(JSONFileBackendTest, jsonFile) { // Check subnet 1. auto subnet = subnets->begin(); + ASSERT_TRUE(subnet != subnets->end()); EXPECT_EQ("192.0.2.0", (*subnet)->get().first.toText()); EXPECT_EQ(24, (*subnet)->get().second); @@ -445,6 +446,7 @@ TEST_F(JSONFileBackendTest, jsonFile) { // Check subnet 2. ++subnet; + ASSERT_TRUE(subnet != subnets->end()); EXPECT_EQ("192.0.3.0", (*subnet)->get().first.toText()); EXPECT_EQ(24, (*subnet)->get().second); @@ -457,6 +459,7 @@ TEST_F(JSONFileBackendTest, jsonFile) { // And finally check subnet 3. ++subnet; + ASSERT_TRUE(subnet != subnets->end()); EXPECT_EQ("192.0.4.0", (*subnet)->get().first.toText()); EXPECT_EQ(24, (*subnet)->get().second); @@ -506,6 +509,7 @@ TEST_F(JSONFileBackendTest, hashComments) { // Check subnet 1. auto subnet = subnets->begin(); + ASSERT_TRUE(subnet != subnets->end()); EXPECT_EQ("192.0.2.0", (*subnet)->get().first.toText()); EXPECT_EQ(22, (*subnet)->get().second); @@ -556,6 +560,7 @@ TEST_F(JSONFileBackendTest, cppLineComments) { // Check subnet 1. auto subnet = subnets->begin(); + ASSERT_TRUE(subnet != subnets->end()); EXPECT_EQ("192.0.2.0", (*subnet)->get().first.toText()); EXPECT_EQ(22, (*subnet)->get().second); @@ -572,7 +577,7 @@ TEST_F(JSONFileBackendTest, cppLineComments) { TEST_F(JSONFileBackendTest, cBlockComments) { string config_c_block_comments = "/* This is a comment. It should be \n" - "ignored. Real config starts in line below*/\n" + "ignored. Real config starts in line below*/\n" "{ \"Dhcp4\": {" "\"interfaces-config\": {" " \"interfaces\": [ \"*\" ]" @@ -606,6 +611,7 @@ TEST_F(JSONFileBackendTest, cBlockComments) { // Check subnet 1. auto subnet = subnets->begin(); + ASSERT_TRUE(subnet != subnets->end()); EXPECT_EQ("192.0.2.0", (*subnet)->get().first.toText()); EXPECT_EQ(22, (*subnet)->get().second); @@ -656,6 +662,7 @@ TEST_F(JSONFileBackendTest, include) { // Check subnet 1. auto subnet = subnets->begin(); + ASSERT_TRUE(subnet != subnets->end()); EXPECT_EQ("192.0.2.0", (*subnet)->get().first.toText()); EXPECT_EQ(22, (*subnet)->get().second); diff --git a/src/bin/dhcp6/tests/kea_controller_unittest.cc b/src/bin/dhcp6/tests/kea_controller_unittest.cc index 720cf9d659..696635b9f2 100644 --- a/src/bin/dhcp6/tests/kea_controller_unittest.cc +++ b/src/bin/dhcp6/tests/kea_controller_unittest.cc @@ -175,6 +175,7 @@ typedef boost::shared_ptr TestCBControlDHCPv6Ptr; /// @c CBControlDHCPv6 object. class NakedControlledDhcpv6Srv: public ControlledDhcpv6Srv { public: + /// @brief Constructor. NakedControlledDhcpv6Srv() : ControlledDhcpv6Srv(0) { @@ -399,6 +400,7 @@ TEST_F(JSONFileBackendTest, jsonFile) { " } ]," "\"valid-lifetime\": 4000 }" "}"; + writeFile(TEST_FILE, config); // Now initialize the server @@ -416,7 +418,6 @@ TEST_F(JSONFileBackendTest, jsonFile) { ASSERT_TRUE(subnets); ASSERT_EQ(3, subnets->size()); // We expect 3 subnets. - // Check subnet 1. auto subnet = subnets->begin(); ASSERT_TRUE(subnet != subnets->end()); @@ -485,7 +486,7 @@ TEST_F(JSONFileBackendTest, hashComments) { srv.reset(new ControlledDhcpv6Srv(0)) ); - // And configure it using config without + // And configure it using config with comments. EXPECT_NO_THROW(srv->init(TEST_FILE)); // Now check if the configuration has been applied correctly. @@ -537,7 +538,7 @@ TEST_F(JSONFileBackendTest, cppLineComments) { srv.reset(new ControlledDhcpv6Srv(0)) ); - // And configure it using config without + // And configure it using config with comments. EXPECT_NO_THROW(srv->init(TEST_FILE)); // Now check if the configuration has been applied correctly. @@ -581,7 +582,7 @@ TEST_F(JSONFileBackendTest, cBlockComments) { "\"valid-lifetime\": 4000 }" "}"; - writeFile(TEST_FILE, config_c_block_comments); + writeFile(TEST_FILE, config_c_block_comments); // Now initialize the server boost::scoped_ptr srv; @@ -589,7 +590,7 @@ TEST_F(JSONFileBackendTest, cBlockComments) { srv.reset(new ControlledDhcpv6Srv(0)) ); - // And configure it using config without + // And configure it using config with comments. EXPECT_NO_THROW(srv->init(TEST_FILE)); // Now check if the configuration has been applied correctly. @@ -641,7 +642,7 @@ TEST_F(JSONFileBackendTest, include) { srv.reset(new ControlledDhcpv6Srv(0)) ); - // And configure it using config without + // And configure it using config with comments. EXPECT_NO_THROW(srv->init(TEST_FILE)); // Now check if the configuration has been applied correctly. @@ -687,14 +688,13 @@ TEST_F(JSONFileBackendTest, recursiveInclude) { writeFile(TEST_FILE, config_recursive_include); writeFile(TEST_INCLUDE, include); - // Now initialize the server boost::scoped_ptr srv; ASSERT_NO_THROW( srv.reset(new ControlledDhcpv6Srv(0)) ); - // And configure it using config + // And configure it using config with comments. try { srv->init(TEST_FILE); FAIL() << "Expected Dhcp6ParseError but nothing was raised"; @@ -704,7 +704,6 @@ TEST_F(JSONFileBackendTest, recursiveInclude) { } } -// This test checks if configuration can be read from a JSON file. // This test checks if configuration detects failure when trying: // - empty file // - empty filename @@ -895,7 +894,6 @@ TEST_F(JSONFileBackendTest, defaultLeaseDbBackend) { EXPECT_NO_THROW(static_cast(LeaseMgrFactory::instance())); } - // This test verifies that the timer triggering configuration updates // is invoked according to the configured value of the // config-fetch-wait-time. @@ -958,7 +956,7 @@ public: /// /// Destroys MySQL schema. virtual ~JSONFileBackendMySQLTest() { - // If data wipe enabled, delete transient data otherwise destroy the schema + // If data wipe enabled, delete transient data otherwise destroy the schema. destroyMySQLSchema(); }