|
48 | 48 |
|
49 | 49 | #include <iostream> |
50 | 50 | #include <cstdlib> |
51 | | -#include <sstream> |
52 | 51 |
|
53 | 52 | #include <arpa/inet.h> |
54 | 53 | #include <dirent.h> |
@@ -1892,8 +1891,7 @@ TEST_F(Dhcpv4SrvTest, DiscoverCache) { |
1892 | 1891 | OptionUint32Ptr opt = boost::dynamic_pointer_cast< |
1893 | 1892 | OptionUint32>(offer->getOption(DHO_DHCP_LEASE_TIME)); |
1894 | 1893 | ASSERT_TRUE(opt); |
1895 | | - EXPECT_GE(subnet_->getValid() - delta, opt->getValue()); |
1896 | | - EXPECT_LE(subnet_->getValid() - delta - 10, opt->getValue()); |
| 1894 | + EXPECT_EQ_MARGIN(subnet_->getValid() - delta, opt->getValue(), 1); |
1897 | 1895 |
|
1898 | 1896 | // Check address |
1899 | 1897 | EXPECT_EQ(addr, offer->getYiaddr()); |
@@ -2074,7 +2072,7 @@ TEST_F(Dhcpv4SrvTest, RenewBasic) { |
2074 | 2072 | int32_t cltt = static_cast<int32_t>(l->cltt_); |
2075 | 2073 | int32_t expected = static_cast<int32_t>(time(NULL)); |
2076 | 2074 | // Equality or difference by 1 between cltt and expected is ok. |
2077 | | - EXPECT_GE(1, abs(cltt - expected)); |
| 2075 | + EXPECT_EQ_MARGIN(cltt, expected, 1); |
2078 | 2076 |
|
2079 | 2077 | Lease4Ptr lease = LeaseMgrFactory::instance().getLease4(addr); |
2080 | 2078 | EXPECT_TRUE(LeaseMgrFactory::instance().deleteLease(lease)); |
@@ -2197,7 +2195,7 @@ TEST_F(Dhcpv4SrvTest, RenewDefaultLifetime) { |
2197 | 2195 | int32_t cltt = static_cast<int32_t>(c.l->cltt_); |
2198 | 2196 | int32_t expected = static_cast<int32_t>(time(NULL)); |
2199 | 2197 | // Equality or difference by 1 between cltt and expected is ok. |
2200 | | - EXPECT_GE(1, abs(cltt - expected)); |
| 2198 | + EXPECT_EQ_MARGIN(cltt, expected, 1); |
2201 | 2199 |
|
2202 | 2200 | Lease4Ptr lease = LeaseMgrFactory::instance().getLease4(c.addr); |
2203 | 2201 | EXPECT_TRUE(LeaseMgrFactory::instance().deleteLease(lease)); |
@@ -2243,7 +2241,7 @@ TEST_F(Dhcpv4SrvTest, RenewHintLifetime) { |
2243 | 2241 | int32_t cltt = static_cast<int32_t>(c.l->cltt_); |
2244 | 2242 | int32_t expected = static_cast<int32_t>(time(NULL)); |
2245 | 2243 | // Equality or difference by 1 between cltt and expected is ok. |
2246 | | - EXPECT_GE(1, abs(cltt - expected)); |
| 2244 | + EXPECT_EQ_MARGIN(cltt, expected, 1); |
2247 | 2245 |
|
2248 | 2246 | Lease4Ptr lease = LeaseMgrFactory::instance().getLease4(c.addr); |
2249 | 2247 | EXPECT_TRUE(LeaseMgrFactory::instance().deleteLease(lease)); |
@@ -2289,7 +2287,7 @@ TEST_F(Dhcpv4SrvTest, RenewMinLifetime) { |
2289 | 2287 | int32_t cltt = static_cast<int32_t>(c.l->cltt_); |
2290 | 2288 | int32_t expected = static_cast<int32_t>(time(NULL)); |
2291 | 2289 | // Equality or difference by 1 between cltt and expected is ok. |
2292 | | - EXPECT_GE(1, abs(cltt - expected)); |
| 2290 | + EXPECT_EQ_MARGIN(cltt, expected, 1); |
2293 | 2291 |
|
2294 | 2292 | Lease4Ptr lease = LeaseMgrFactory::instance().getLease4(c.addr); |
2295 | 2293 | EXPECT_TRUE(LeaseMgrFactory::instance().deleteLease(lease)); |
@@ -2334,7 +2332,7 @@ TEST_F(Dhcpv4SrvTest, RenewMaxLifetime) { |
2334 | 2332 | int32_t cltt = static_cast<int32_t>(c.l->cltt_); |
2335 | 2333 | int32_t expected = static_cast<int32_t>(time(NULL)); |
2336 | 2334 | // Equality or difference by 1 between cltt and expected is ok. |
2337 | | - EXPECT_GE(1, abs(cltt - expected)); |
| 2335 | + EXPECT_EQ_MARGIN(cltt, expected, 1); |
2338 | 2336 |
|
2339 | 2337 | Lease4Ptr lease = LeaseMgrFactory::instance().getLease4(c.addr); |
2340 | 2338 | EXPECT_TRUE(LeaseMgrFactory::instance().deleteLease(lease)); |
@@ -2402,8 +2400,7 @@ TEST_F(Dhcpv4SrvTest, RenewCache) { |
2402 | 2400 | OptionUint32Ptr opt = boost::dynamic_pointer_cast< |
2403 | 2401 | OptionUint32>(ack->getOption(DHO_DHCP_LEASE_TIME)); |
2404 | 2402 | ASSERT_TRUE(opt); |
2405 | | - EXPECT_GE(subnet_->getValid() - delta, opt->getValue()); |
2406 | | - EXPECT_LE(subnet_->getValid() - delta - 10, opt->getValue()); |
| 2403 | + EXPECT_EQ_MARGIN(subnet_->getValid() - delta, opt->getValue(), 1); |
2407 | 2404 |
|
2408 | 2405 | // Check address |
2409 | 2406 | EXPECT_EQ(addr, ack->getYiaddr()); |
|
0 commit comments