mgmt: add FaceStatus::unsetExpirationPeriod()
For consistency with Route.
Change-Id: Ieac12ebd7fc7270c03d331c48747bd913f79fef9
Refs: #3903
diff --git a/src/mgmt/nfd/face-status.cpp b/src/mgmt/nfd/face-status.cpp
index df0521f..53ccf61 100644
--- a/src/mgmt/nfd/face-status.cpp
+++ b/src/mgmt/nfd/face-status.cpp
@@ -264,6 +264,14 @@
}
FaceStatus&
+FaceStatus::unsetExpirationPeriod()
+{
+ m_wire.reset();
+ m_expirationPeriod = nullopt;
+ return *this;
+}
+
+FaceStatus&
FaceStatus::setNInInterests(uint64_t nInInterests)
{
m_wire.reset();
diff --git a/src/mgmt/nfd/face-status.hpp b/src/mgmt/nfd/face-status.hpp
index bde34b8..32c2607 100644
--- a/src/mgmt/nfd/face-status.hpp
+++ b/src/mgmt/nfd/face-status.hpp
@@ -74,6 +74,9 @@
FaceStatus&
setExpirationPeriod(time::milliseconds expirationPeriod);
+ FaceStatus&
+ unsetExpirationPeriod();
+
uint64_t
getNInInterests() const
{
diff --git a/tests/unit-tests/mgmt/nfd/face-status.t.cpp b/tests/unit-tests/mgmt/nfd/face-status.t.cpp
index 47fefae..d2342f2 100644
--- a/tests/unit-tests/mgmt/nfd/face-status.t.cpp
+++ b/tests/unit-tests/mgmt/nfd/face-status.t.cpp
@@ -130,6 +130,19 @@
" )");
}
+BOOST_AUTO_TEST_CASE(ExpirationPeriod)
+{
+ FaceStatus status;
+ BOOST_CHECK_EQUAL(status.hasExpirationPeriod(), false);
+
+ status.setExpirationPeriod(time::minutes(1));
+ BOOST_REQUIRE_EQUAL(status.hasExpirationPeriod(), true);
+ BOOST_CHECK_EQUAL(status.getExpirationPeriod(), time::minutes(1));
+
+ status.unsetExpirationPeriod();
+ BOOST_CHECK_EQUAL(status.hasExpirationPeriod(), false);
+}
+
BOOST_AUTO_TEST_CASE(FlagBit)
{
FaceStatus status;
diff --git a/tests/unit-tests/mgmt/nfd/rib-entry.t.cpp b/tests/unit-tests/mgmt/nfd/rib-entry.t.cpp
index cc3ed58..28e4fd7 100644
--- a/tests/unit-tests/mgmt/nfd/rib-entry.t.cpp
+++ b/tests/unit-tests/mgmt/nfd/rib-entry.t.cpp
@@ -83,6 +83,27 @@
BOOST_CHECK_EQUAL(route1, route2);
}
+BOOST_AUTO_TEST_CASE(RouteExpirationPeriod)
+{
+ Route route;
+ BOOST_CHECK_EQUAL(route.hasExpirationPeriod(), false);
+ BOOST_CHECK_EQUAL(route.getExpirationPeriod(), time::milliseconds::max());
+
+ route.setExpirationPeriod(time::minutes(1));
+ BOOST_CHECK_EQUAL(route.hasExpirationPeriod(), true);
+ BOOST_CHECK_EQUAL(route.getExpirationPeriod(), time::minutes(1));
+
+ route.setExpirationPeriod(time::milliseconds::max());
+ BOOST_CHECK_EQUAL(route.hasExpirationPeriod(), false);
+ BOOST_CHECK_EQUAL(route.getExpirationPeriod(), time::milliseconds::max());
+
+ route.setExpirationPeriod(time::minutes(1));
+ BOOST_CHECK_EQUAL(route.hasExpirationPeriod(), true);
+
+ route.unsetExpirationPeriod();
+ BOOST_CHECK_EQUAL(route.hasExpirationPeriod(), false);
+}
+
BOOST_AUTO_TEST_CASE(RouteEquality)
{
Route route1, route2;