diff options
author | Marcin Siodelski <marcin@isc.org> | 2023-01-09 20:46:54 +0100 |
---|---|---|
committer | Marcin Siodelski <marcin@isc.org> | 2023-01-09 20:46:54 +0100 |
commit | c4c53a0168ffa385c387ba685ac16e5544feaad4 (patch) | |
tree | 3c12be7f99956d4619449c84b7b3b8c640a1feb7 | |
parent | [#969] Removed duplicated tests (diff) | |
download | kea-c4c53a0168ffa385c387ba685ac16e5544feaad4.tar.xz kea-c4c53a0168ffa385c387ba685ac16e5544feaad4.zip |
[#969] Addressed remaining review comments
-rw-r--r-- | src/lib/dhcpsrv/tests/random_allocator_unittest.cc | 22 | ||||
-rw-r--r-- | src/lib/dhcpsrv/tests/shared_network_unittest.cc | 6 |
2 files changed, 15 insertions, 13 deletions
diff --git a/src/lib/dhcpsrv/tests/random_allocator_unittest.cc b/src/lib/dhcpsrv/tests/random_allocator_unittest.cc index dc0e42003f..d795c5d276 100644 --- a/src/lib/dhcpsrv/tests/random_allocator_unittest.cc +++ b/src/lib/dhcpsrv/tests/random_allocator_unittest.cc @@ -80,28 +80,29 @@ TEST_F(RandomAllocatorTest4, manyPools) { // Verify that the addresses are returned in the random order. // Count how many times we found consecutive addresses. It should // be 0 or close to 0. - int consecutives = 0; + int consecutive_addresses = 0; for (auto k = 0; k < addresses_vector.size()-1; ++k) { if (addresses_vector[k].toUint32() == addresses_vector[k+1].toUint32()-1) { - ++consecutives; + ++consecutive_addresses; } } // Ideally, the number of consecutive occurrences should be 0 but we // allow some to make sure the test doesn't fall over sporadically. - EXPECT_LT(consecutives, addresses_vector.size()/4); + EXPECT_LT(consecutive_addresses, addresses_vector.size()/4); // Repeat similar check for pools. The pools should be picked in the // random order too. + int consecutive_pools = 0; for (auto k = 0; k < pools_vector.size()-1; ++k) { // Check if the pools are adjacent (i.e., last address of the // previous pool is a neighbor of the first address of the next // pool). if (pools_vector[k]->getLastAddress().toUint32()+1 == pools_vector[k+1]->getFirstAddress().toUint32()) { - ++consecutives; + ++consecutive_pools; } } - EXPECT_LT(consecutives, pools_vector.size()/2); + EXPECT_LT(consecutive_pools, pools_vector.size()/2); } } @@ -236,25 +237,26 @@ TEST_F(RandomAllocatorTest6, manyPools) { // Verify that the addresses are returned in the random order. // Count how many times we found consecutive addresses. It should // be 0 or close to 0. - int consecutives = 0; + int consecutive_addresses = 0; for (auto k = 0; k < addresses_vector.size()-1; ++k) { if (IOAddress::increase(addresses_vector[k]) == addresses_vector[k+1]) { - ++consecutives; + ++consecutive_addresses; } } // Ideally, the number of consecutive occurrences should be 0 but we // allow some to make sure the test doesn't fall over sporadically. - EXPECT_LT(consecutives, addresses_vector.size()/4); + EXPECT_LT(consecutive_addresses, addresses_vector.size()/4); // Repeat similar check for pools. The pools should be picked in the // random order too. + int consecutive_pools = 0; for (auto k = 0; k < pools_vector.size()-1; ++k) { if (IOAddress::increase(pools_vector[k]->getLastAddress()) == pools_vector[k]->getFirstAddress()) { - ++consecutives; + ++consecutive_pools; } } - EXPECT_LT(consecutives, pools_vector.size()/2); + EXPECT_LT(consecutive_pools, pools_vector.size()/2); } } diff --git a/src/lib/dhcpsrv/tests/shared_network_unittest.cc b/src/lib/dhcpsrv/tests/shared_network_unittest.cc index a2da43c8b4..d145233fe6 100644 --- a/src/lib/dhcpsrv/tests/shared_network_unittest.cc +++ b/src/lib/dhcpsrv/tests/shared_network_unittest.cc @@ -41,7 +41,7 @@ typedef boost::shared_ptr<TestSubnetIterativeAllocationState> TestSubnetIterativ class TestSubnetIterativeAllocationState : public SubnetIterativeAllocationState { public: - /// @brief Creates the state instamce. + /// @brief Creates the state instance. /// /// @param subnet subnet instance for which the state is created. /// @return state instance. @@ -494,8 +494,8 @@ TEST(SharedNetwork4Test, getPreferredSubnet) { EXPECT_EQ(subnet4->getID(), preferred->getID()); // Same for subnet5. - preferred = network->getPreferredSubnet(subnet4); - EXPECT_EQ(subnet4->getID(), preferred->getID()); + preferred = network->getPreferredSubnet(subnet5); + EXPECT_EQ(subnet5->getID(), preferred->getID()); // Allocate an address from the subnet3. This makes it preferred to // subnet4 and subnet5. |