Browse Source

[3171] All dhcpsrv unit-tests now pass.

Tomek Mrugalski 11 years ago
parent
commit
8ed4c169ac
2 changed files with 9 additions and 23 deletions
  1. 3 17
      src/lib/dhcpsrv/subnet.cc
  2. 6 6
      src/lib/dhcpsrv/tests/subnet_unittest.cc

+ 3 - 17
src/lib/dhcpsrv/subnet.cc

@@ -169,28 +169,15 @@ const PoolCollection& Subnet::getPools(Lease::Type type) const {
 }
 }
 
 
 PoolCollection& Subnet::getPools(Lease::Type type) {
 PoolCollection& Subnet::getPools(Lease::Type type) {
-    switch (type) {
-    case Lease::TYPE_V4:
-    case Lease::TYPE_NA:
-        return (pools_);
-    case Lease::TYPE_TA:
-        return (pools_);
-    case Lease::TYPE_PD:
-        return (pools_pd_);
-    default:
-        isc_throw(BadValue, "Invalid pool type specified: "
-                  << static_cast<int>(type));
-    }
-}
+    // check if the type is valid (and throw if it isn't)
+    checkType(type);
 
 
-#if 0
-const PoolCollection& Subnet::getConstPools(Lease::Type type) const {
     switch (type) {
     switch (type) {
     case Lease::TYPE_V4:
     case Lease::TYPE_V4:
     case Lease::TYPE_NA:
     case Lease::TYPE_NA:
         return (pools_);
         return (pools_);
     case Lease::TYPE_TA:
     case Lease::TYPE_TA:
-        return (pools_);
+        return (pools_ta_);
     case Lease::TYPE_PD:
     case Lease::TYPE_PD:
         return (pools_pd_);
         return (pools_pd_);
     default:
     default:
@@ -198,7 +185,6 @@ const PoolCollection& Subnet::getConstPools(Lease::Type type) const {
                   << static_cast<int>(type));
                   << static_cast<int>(type));
     }
     }
 }
 }
-#endif
 
 
 PoolPtr Subnet::getPool(Lease::Type type, isc::asiolink::IOAddress hint,
 PoolPtr Subnet::getPool(Lease::Type type, isc::asiolink::IOAddress hint,
                         bool anypool /* true */) {
                         bool anypool /* true */) {

+ 6 - 6
src/lib/dhcpsrv/tests/subnet_unittest.cc

@@ -609,27 +609,27 @@ TEST(Subnet6Test, inRangeinPool) {
     // 192.1.1.1 belongs to the subnet...
     // 192.1.1.1 belongs to the subnet...
     EXPECT_TRUE(subnet->inRange(IOAddress("2001:db8::1")));
     EXPECT_TRUE(subnet->inRange(IOAddress("2001:db8::1")));
     // ... but it does not belong to any pool within
     // ... but it does not belong to any pool within
-    EXPECT_FALSE(subnet->inPool(Lease::TYPE_V4, IOAddress("2001:db8::1")));
+    EXPECT_FALSE(subnet->inPool(Lease::TYPE_NA, IOAddress("2001:db8::1")));
 
 
     // the last address that is in range, but out of pool
     // the last address that is in range, but out of pool
     EXPECT_TRUE(subnet->inRange(IOAddress("2001:db8::f")));
     EXPECT_TRUE(subnet->inRange(IOAddress("2001:db8::f")));
-    EXPECT_FALSE(subnet->inPool(Lease::TYPE_V4, IOAddress("2001:db8::f")));
+    EXPECT_FALSE(subnet->inPool(Lease::TYPE_NA, IOAddress("2001:db8::f")));
 
 
     // the first address that is in range, in pool
     // the first address that is in range, in pool
     EXPECT_TRUE(subnet->inRange(IOAddress("2001:db8::10")));
     EXPECT_TRUE(subnet->inRange(IOAddress("2001:db8::10")));
-    EXPECT_TRUE (subnet->inPool(Lease::TYPE_V4, IOAddress("2001:db8::10")));
+    EXPECT_TRUE (subnet->inPool(Lease::TYPE_NA, IOAddress("2001:db8::10")));
 
 
     // let's try something in the middle as well
     // let's try something in the middle as well
     EXPECT_TRUE(subnet->inRange(IOAddress("2001:db8::18")));
     EXPECT_TRUE(subnet->inRange(IOAddress("2001:db8::18")));
-    EXPECT_TRUE (subnet->inPool(Lease::TYPE_V4, IOAddress("2001:db8::18")));
+    EXPECT_TRUE (subnet->inPool(Lease::TYPE_NA, IOAddress("2001:db8::18")));
 
 
     // the last address that is in range, in pool
     // the last address that is in range, in pool
     EXPECT_TRUE(subnet->inRange(IOAddress("2001:db8::20")));
     EXPECT_TRUE(subnet->inRange(IOAddress("2001:db8::20")));
-    EXPECT_TRUE (subnet->inPool(Lease::TYPE_V4, IOAddress("2001:db8::20")));
+    EXPECT_TRUE (subnet->inPool(Lease::TYPE_NA, IOAddress("2001:db8::20")));
 
 
     // the first address that is in range, but out of pool
     // the first address that is in range, but out of pool
     EXPECT_TRUE(subnet->inRange(IOAddress("2001:db8::21")));
     EXPECT_TRUE(subnet->inRange(IOAddress("2001:db8::21")));
-    EXPECT_FALSE(subnet->inPool(Lease::TYPE_V4, IOAddress("2001:db8::21")));
+    EXPECT_FALSE(subnet->inPool(Lease::TYPE_NA, IOAddress("2001:db8::21")));
 }
 }
 
 
 // This test checks if the toText() method returns text representation
 // This test checks if the toText() method returns text representation