]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[4339] Fixed issues with hostname generation in new unit test.
authorMarcin Siodelski <marcin@isc.org>
Mon, 21 Mar 2016 13:07:04 +0000 (14:07 +0100)
committerMarcin Siodelski <marcin@isc.org>
Mon, 21 Mar 2016 13:07:04 +0000 (14:07 +0100)
src/lib/dhcpsrv/tests/memfile_lease_mgr_unittest.cc

index 4daa60c685066d33344f7bad554e0c45953f5937..c27ec1e75cb2aaa5dbc3acf6938d4277c0d1eeaa 100644 (file)
@@ -275,21 +275,14 @@ public:
         bool fqdn_rev = false;
         uint32_t subnet_id = 1000 + rand()%16;
 
-        string hostname;
-        hostname.resize(rand()%32);
-        for (int i = 0; i < hostname.size(); i++) {
-            // this should generate random garbage consisting of
-            // printable characters from between
-            // 33 (!, first printable character after space) to
-            // 126 (~, the last surely printable character)
-            hostname[i] = static_cast<char>(33 + rand()%93);
-        }
+        std::ostringstream hostname;
+        hostname << "hostname" << (rand() % 2048);
 
         // Return created lease.
         return (Lease4Ptr(new Lease4(address, hwaddr, &clientid[0],
                                      clientid.size(), valid_lft, t1, t2,
                                      timestamp, subnet_id, fqdn_fwd,
-                                     fqdn_rev, hostname)));
+                                     fqdn_rev, hostname.str())));
     }
 
     /// @brief Generates a DHCPv6 lease with random content.
@@ -334,20 +327,14 @@ public:
         bool fqdn_rev = false;
         uint32_t subnet_id = 1000 + rand()%16;
 
-        std::string hostname;
-        hostname.resize(rand()%32);
-        for (int i = 0; i < hostname.size(); i++) {
-            // this should generate random garbage consisting of
-            // printable characters from between
-            // 33 (!, first printable character after space) to
-            // 126 (~, the last surely printable character)
-            hostname[i] = static_cast<char>(33 + rand()%93);
-        }
+        std::ostringstream hostname;
+        hostname << "hostname" << (rand() % 2048);
 
         // Return created lease.
         Lease6Ptr lease(new Lease6(lease_type, address, duid, iaid,
                                    preferred_lft, valid_lft, t1, t2,
-                                   subnet_id, fqdn_fwd, fqdn_rev, hostname));
+                                   subnet_id, fqdn_fwd, fqdn_rev,
+                                   hostname.str()));
         lease->cltt_ = timestamp;
         return (lease);
     }