#include <iostream>
#include <cstdlib>
-#include <sstream>
#include <arpa/inet.h>
#include <dirent.h>
OptionUint32Ptr opt = boost::dynamic_pointer_cast<
OptionUint32>(offer->getOption(DHO_DHCP_LEASE_TIME));
ASSERT_TRUE(opt);
- EXPECT_GE(subnet_->getValid() - delta, opt->getValue());
- EXPECT_LE(subnet_->getValid() - delta - 10, opt->getValue());
+ EXPECT_EQ_MARGIN(subnet_->getValid() - delta, opt->getValue(), 1);
// Check address
EXPECT_EQ(addr, offer->getYiaddr());
int32_t cltt = static_cast<int32_t>(l->cltt_);
int32_t expected = static_cast<int32_t>(time(NULL));
// Equality or difference by 1 between cltt and expected is ok.
- EXPECT_GE(1, abs(cltt - expected));
+ EXPECT_EQ_MARGIN(cltt, expected, 1);
Lease4Ptr lease = LeaseMgrFactory::instance().getLease4(addr);
EXPECT_TRUE(LeaseMgrFactory::instance().deleteLease(lease));
int32_t cltt = static_cast<int32_t>(c.l->cltt_);
int32_t expected = static_cast<int32_t>(time(NULL));
// Equality or difference by 1 between cltt and expected is ok.
- EXPECT_GE(1, abs(cltt - expected));
+ EXPECT_EQ_MARGIN(cltt, expected, 1);
Lease4Ptr lease = LeaseMgrFactory::instance().getLease4(c.addr);
EXPECT_TRUE(LeaseMgrFactory::instance().deleteLease(lease));
int32_t cltt = static_cast<int32_t>(c.l->cltt_);
int32_t expected = static_cast<int32_t>(time(NULL));
// Equality or difference by 1 between cltt and expected is ok.
- EXPECT_GE(1, abs(cltt - expected));
+ EXPECT_EQ_MARGIN(cltt, expected, 1);
Lease4Ptr lease = LeaseMgrFactory::instance().getLease4(c.addr);
EXPECT_TRUE(LeaseMgrFactory::instance().deleteLease(lease));
int32_t cltt = static_cast<int32_t>(c.l->cltt_);
int32_t expected = static_cast<int32_t>(time(NULL));
// Equality or difference by 1 between cltt and expected is ok.
- EXPECT_GE(1, abs(cltt - expected));
+ EXPECT_EQ_MARGIN(cltt, expected, 1);
Lease4Ptr lease = LeaseMgrFactory::instance().getLease4(c.addr);
EXPECT_TRUE(LeaseMgrFactory::instance().deleteLease(lease));
int32_t cltt = static_cast<int32_t>(c.l->cltt_);
int32_t expected = static_cast<int32_t>(time(NULL));
// Equality or difference by 1 between cltt and expected is ok.
- EXPECT_GE(1, abs(cltt - expected));
+ EXPECT_EQ_MARGIN(cltt, expected, 1);
Lease4Ptr lease = LeaseMgrFactory::instance().getLease4(c.addr);
EXPECT_TRUE(LeaseMgrFactory::instance().deleteLease(lease));
OptionUint32Ptr opt = boost::dynamic_pointer_cast<
OptionUint32>(ack->getOption(DHO_DHCP_LEASE_TIME));
ASSERT_TRUE(opt);
- EXPECT_GE(subnet_->getValid() - delta, opt->getValue());
- EXPECT_LE(subnet_->getValid() - delta - 10, opt->getValue());
+ EXPECT_EQ_MARGIN(subnet_->getValid() - delta, opt->getValue(), 1);
// Check address
EXPECT_EQ(addr, ack->getYiaddr());
#include <boost/pointer_cast.hpp>
#include <boost/scoped_ptr.hpp>
-#include <fstream>
#include <iostream>
-#include <sstream>
#include <dirent.h>
#include <unistd.h>
// Check the address.
EXPECT_EQ(addr, iaaddr->getAddress());
- EXPECT_EQ(pref - delta, iaaddr->getPreferred());
- EXPECT_EQ(valid - delta, iaaddr->getValid());
+
+ // Since the initial time values were set, one second could have ticked,
+ // so allow one second of margin error.
+ EXPECT_EQ_MARGIN(pref - delta, iaaddr->getPreferred(), 1);
+ EXPECT_EQ_MARGIN(valid - delta, iaaddr->getValid(), 1);
// check DUIDs
checkServerId(reply, srv.getServerID());
// Check the prefix.
EXPECT_EQ(prefix, iapref->getAddress());
EXPECT_EQ(prefixlen, iapref->getLength());
- EXPECT_EQ(pref - delta, iapref->getPreferred());
- EXPECT_EQ(valid - delta, iapref->getValid());
+ EXPECT_EQ_MARGIN(pref - delta, iapref->getPreferred(), 1);
+ EXPECT_EQ_MARGIN(valid - delta, iapref->getValid(), 1);
// check DUIDs
checkServerId(reply, srv.getServerID());
// Check the address.
EXPECT_EQ(addr, iaaddr->getAddress());
- EXPECT_EQ(pref - delta, iaaddr->getPreferred());
- EXPECT_EQ(valid - delta, iaaddr->getValid());
+ EXPECT_EQ_MARGIN(pref - delta, iaaddr->getPreferred(), 1);
+ EXPECT_EQ_MARGIN(valid - delta, iaaddr->getValid(), 1);
// check DUIDs
checkServerId(reply, srv.getServerID());
// Check the prefix.
EXPECT_EQ(prefix, iapref->getAddress());
EXPECT_EQ(prefixlen, iapref->getLength());
- EXPECT_EQ(pref - delta, iapref->getPreferred());
- EXPECT_EQ(valid - delta, iapref->getValid());
+ EXPECT_EQ_MARGIN(pref - delta, iapref->getPreferred(), 1);
+ EXPECT_EQ_MARGIN(valid - delta, iapref->getValid(), 1);
// check DUIDs
checkServerId(reply, srv.getServerID());