]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[#1265] fixed comments and added asserts
authorRazvan Becheriu <razvan@isc.org>
Mon, 27 Jul 2020 11:49:12 +0000 (14:49 +0300)
committerRazvan Becheriu <razvan@isc.org>
Mon, 27 Jul 2020 12:34:16 +0000 (15:34 +0300)
src/bin/dhcp4/tests/kea_controller_unittest.cc
src/bin/dhcp6/tests/kea_controller_unittest.cc

index d6054e07f95a90d372eecd3d1adc6009b0559d38..ea3fcd479bfc33a8d5fe9c2c91dd4b66e0072bbc 100644 (file)
@@ -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);
 
index 720cf9d6598425cce2a4776f04d3153436fb3187..696635b9f2c163d913de68eb7acec55624c7d38b 100644 (file)
@@ -175,6 +175,7 @@ typedef boost::shared_ptr<TestCBControlDHCPv6> 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<ControlledDhcpv6Srv> 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<ControlledDhcpv6Srv> 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<void>(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();
     }