2
0
mirror of https://gitlab.isc.org/isc-projects/kea synced 2025-08-30 05:27:55 +00:00

[#3163] EXPECT_EQ_MARGIN -> EXPECT_NEAR

This commit is contained in:
Andrei Pavel 2024-04-30 14:50:11 +03:00
parent f40fa49ab9
commit 4891f55241
No known key found for this signature in database
GPG Key ID: D4E804481939CB21
3 changed files with 20 additions and 20 deletions

View File

@ -1891,7 +1891,7 @@ TEST_F(Dhcpv4SrvTest, DiscoverCache) {
OptionUint32Ptr opt = boost::dynamic_pointer_cast<
OptionUint32>(offer->getOption(DHO_DHCP_LEASE_TIME));
ASSERT_TRUE(opt);
EXPECT_EQ_MARGIN(subnet_->getValid() - delta, opt->getValue(), 1);
EXPECT_NEAR(subnet_->getValid() - delta, opt->getValue(), 1);
// Check address
EXPECT_EQ(addr, offer->getYiaddr());
@ -2072,7 +2072,7 @@ TEST_F(Dhcpv4SrvTest, RenewBasic) {
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_EQ_MARGIN(cltt, expected, 1);
EXPECT_NEAR(cltt, expected, 1);
Lease4Ptr lease = LeaseMgrFactory::instance().getLease4(addr);
EXPECT_TRUE(LeaseMgrFactory::instance().deleteLease(lease));
@ -2195,7 +2195,7 @@ TEST_F(Dhcpv4SrvTest, RenewDefaultLifetime) {
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_EQ_MARGIN(cltt, expected, 1);
EXPECT_NEAR(cltt, expected, 1);
Lease4Ptr lease = LeaseMgrFactory::instance().getLease4(c.addr);
EXPECT_TRUE(LeaseMgrFactory::instance().deleteLease(lease));
@ -2241,7 +2241,7 @@ TEST_F(Dhcpv4SrvTest, RenewHintLifetime) {
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_EQ_MARGIN(cltt, expected, 1);
EXPECT_NEAR(cltt, expected, 1);
Lease4Ptr lease = LeaseMgrFactory::instance().getLease4(c.addr);
EXPECT_TRUE(LeaseMgrFactory::instance().deleteLease(lease));
@ -2287,7 +2287,7 @@ TEST_F(Dhcpv4SrvTest, RenewMinLifetime) {
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_EQ_MARGIN(cltt, expected, 1);
EXPECT_NEAR(cltt, expected, 1);
Lease4Ptr lease = LeaseMgrFactory::instance().getLease4(c.addr);
EXPECT_TRUE(LeaseMgrFactory::instance().deleteLease(lease));
@ -2332,7 +2332,7 @@ TEST_F(Dhcpv4SrvTest, RenewMaxLifetime) {
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_EQ_MARGIN(cltt, expected, 1);
EXPECT_NEAR(cltt, expected, 1);
Lease4Ptr lease = LeaseMgrFactory::instance().getLease4(c.addr);
EXPECT_TRUE(LeaseMgrFactory::instance().deleteLease(lease));
@ -2400,7 +2400,7 @@ TEST_F(Dhcpv4SrvTest, RenewCache) {
OptionUint32Ptr opt = boost::dynamic_pointer_cast<
OptionUint32>(ack->getOption(DHO_DHCP_LEASE_TIME));
ASSERT_TRUE(opt);
EXPECT_EQ_MARGIN(subnet_->getValid() - delta, opt->getValue(), 1);
EXPECT_NEAR(subnet_->getValid() - delta, opt->getValue(), 1);
// Check address
EXPECT_EQ(addr, ack->getYiaddr());

View File

@ -1707,8 +1707,8 @@ TEST_F(Dhcpv6SrvTest, RequestCache) {
// 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);
EXPECT_NEAR(pref - delta, iaaddr->getPreferred(), 1);
EXPECT_NEAR(valid - delta, iaaddr->getValid(), 1);
// check DUIDs
checkServerId(reply, srv.getServerID());
@ -1782,8 +1782,8 @@ TEST_F(Dhcpv6SrvTest, pdRequestCache) {
// Check the prefix.
EXPECT_EQ(prefix, iapref->getAddress());
EXPECT_EQ(prefixlen, iapref->getLength());
EXPECT_EQ_MARGIN(pref - delta, iapref->getPreferred(), 1);
EXPECT_EQ_MARGIN(valid - delta, iapref->getValid(), 1);
EXPECT_NEAR(pref - delta, iapref->getPreferred(), 1);
EXPECT_NEAR(valid - delta, iapref->getValid(), 1);
// check DUIDs
checkServerId(reply, srv.getServerID());
@ -1997,8 +1997,8 @@ TEST_F(Dhcpv6SrvTest, RenewCache) {
// Check the address.
EXPECT_EQ(addr, iaaddr->getAddress());
EXPECT_EQ_MARGIN(pref - delta, iaaddr->getPreferred(), 1);
EXPECT_EQ_MARGIN(valid - delta, iaaddr->getValid(), 1);
EXPECT_NEAR(pref - delta, iaaddr->getPreferred(), 1);
EXPECT_NEAR(valid - delta, iaaddr->getValid(), 1);
// check DUIDs
checkServerId(reply, srv.getServerID());
@ -2072,8 +2072,8 @@ TEST_F(Dhcpv6SrvTest, pdRenewCache) {
// Check the prefix.
EXPECT_EQ(prefix, iapref->getAddress());
EXPECT_EQ(prefixlen, iapref->getLength());
EXPECT_EQ_MARGIN(pref - delta, iapref->getPreferred(), 1);
EXPECT_EQ_MARGIN(valid - delta, iapref->getValid(), 1);
EXPECT_NEAR(pref - delta, iapref->getPreferred(), 1);
EXPECT_NEAR(valid - delta, iapref->getValid(), 1);
// check DUIDs
checkServerId(reply, srv.getServerID());

View File

@ -55,8 +55,8 @@ detailCompareLease(const Lease4Ptr& first, const Lease4Ptr& second) {
// Since the initial time values were set, one second could have ticked,
// so allow one second of margin error.
EXPECT_EQ_MARGIN(first->valid_lft_, second->valid_lft_, 1);
EXPECT_EQ_MARGIN(first->cltt_, second->cltt_, 1);
EXPECT_NEAR(first->valid_lft_, second->valid_lft_, 1);
EXPECT_NEAR(first->cltt_, second->cltt_, 1);
EXPECT_EQ(first->subnet_id_, second->subnet_id_);
EXPECT_EQ(first->pool_id_, second->pool_id_);
@ -92,9 +92,9 @@ detailCompareLease(const Lease6Ptr& first, const Lease6Ptr& second) {
// Since the initial time values were set, one second could have ticked,
// so allow one second of margin error.
EXPECT_EQ_MARGIN(first->preferred_lft_, second->preferred_lft_, 1);
EXPECT_EQ_MARGIN(first->valid_lft_, second->valid_lft_, 1);
EXPECT_EQ_MARGIN(first->cltt_, second->cltt_, 1);
EXPECT_NEAR(first->preferred_lft_, second->preferred_lft_, 1);
EXPECT_NEAR(first->valid_lft_, second->valid_lft_, 1);
EXPECT_NEAR(first->cltt_, second->cltt_, 1);
EXPECT_EQ(first->subnet_id_, second->subnet_id_);
EXPECT_EQ(first->pool_id_, second->pool_id_);