tests+tools: minor code cleanup
Change-Id: Ic3356d4a18a8e5eeb45fc076fc0563c3d1549c8a
diff --git a/tests/daemon/rib/fib-updates-common.hpp b/tests/daemon/rib/fib-updates-common.hpp
index 77348be..9afd4a5 100644
--- a/tests/daemon/rib/fib-updates-common.hpp
+++ b/tests/daemon/rib/fib-updates-common.hpp
@@ -38,30 +38,9 @@
namespace rib {
namespace tests {
-inline bool
-compareNameFaceIdCostAction(const FibUpdate& lhs, const FibUpdate& rhs)
-{
- if (lhs.name < rhs.name) {
- return true;
- }
- else if (lhs.name == rhs.name) {
- if (lhs.faceId < rhs.faceId) {
- return true;
- }
- else if (lhs.faceId == rhs.faceId) {
- if (lhs.cost < rhs.cost) {
- return true;
- }
- else if (lhs.cost == rhs.cost) {
- return lhs.action < rhs.action;
- }
- }
- }
+using namespace nfd::tests;
- return false;
-}
-
-class FibUpdatesFixture : public nfd::tests::GlobalIoFixture, public nfd::tests::KeyChainFixture
+class FibUpdatesFixture : public GlobalIoFixture, public KeyChainFixture
{
public:
FibUpdatesFixture()
@@ -125,7 +104,10 @@
getSortedFibUpdates()
{
FibUpdater::FibUpdateList updates = getFibUpdates();
- updates.sort(&compareNameFaceIdCostAction);
+ updates.sort([] (const auto& lhs, const auto& rhs) {
+ return std::tie(lhs.name, lhs.faceId, lhs.cost, lhs.action) <
+ std::tie(rhs.name, rhs.faceId, rhs.cost, rhs.action);
+ });
return updates;
}
diff --git a/tests/daemon/rib/readvertise/host-to-gateway-readvertise-policy.t.cpp b/tests/daemon/rib/readvertise/host-to-gateway-readvertise-policy.t.cpp
index 94120c0..494eac2 100644
--- a/tests/daemon/rib/readvertise/host-to-gateway-readvertise-policy.t.cpp
+++ b/tests/daemon/rib/readvertise/host-to-gateway-readvertise-policy.t.cpp
@@ -96,16 +96,16 @@
BOOST_AUTO_TEST_CASE(LoadRefreshInterval)
{
auto policy = makePolicy();
- BOOST_CHECK_EQUAL(policy->getRefreshInterval(), time::seconds(25)); // default setting is 25
+ BOOST_CHECK_EQUAL(policy->getRefreshInterval(), 25_s); // default setting is 25
ConfigSection section;
section.put("refresh_interval_wrong", 10);
policy = makePolicy(section);
- BOOST_CHECK_EQUAL(policy->getRefreshInterval(), time::seconds(25)); // wrong formate
+ BOOST_CHECK_EQUAL(policy->getRefreshInterval(), 25_s); // wrong formate
section.put("refresh_interval", 10);
policy = makePolicy(section);
- BOOST_CHECK_EQUAL(policy->getRefreshInterval(), time::seconds(10));
+ BOOST_CHECK_EQUAL(policy->getRefreshInterval(), 10_s);
}
BOOST_AUTO_TEST_SUITE_END() // TestHostToGatewayReadvertisePolicy
diff --git a/tests/daemon/rib/readvertise/nfd-rib-readvertise-destination.t.cpp b/tests/daemon/rib/readvertise/nfd-rib-readvertise-destination.t.cpp
index 690a53b..5a64bbe 100644
--- a/tests/daemon/rib/readvertise/nfd-rib-readvertise-destination.t.cpp
+++ b/tests/daemon/rib/readvertise/nfd-rib-readvertise-destination.t.cpp
@@ -125,7 +125,7 @@
const Name RIB_REGISTER_COMMAND_PREFIX("/localhost/nlsr/rib/register");
dest.advertise(rr, successCallback, failureCallback);
- advanceClocks(time::milliseconds(100));
+ advanceClocks(100_ms);
// Retrieve the sent Interest to build the response
BOOST_REQUIRE_EQUAL(face.sentInterests.size(), 1);
@@ -142,7 +142,7 @@
auto responseData = makeData(sentInterest.getName());
responseData->setContent(responsePayload.wireEncode());
face.receive(*responseData);
- this->advanceClocks(time::milliseconds(10));
+ this->advanceClocks(10_ms);
scenario.checkCommandOutcome(this);
}
@@ -203,7 +203,7 @@
const Name RIB_UNREGISTER_COMMAND_PREFIX("/localhost/nlsr/rib/unregister");
dest.withdraw(rr, successCallback, failureCallback);
- this->advanceClocks(time::milliseconds(10));
+ this->advanceClocks(10_ms);
// Retrieve the sent Interest to build the response
BOOST_REQUIRE_EQUAL(face.sentInterests.size(), 1);
@@ -220,7 +220,7 @@
responseData->setContent(responsePayload.wireEncode());
face.receive(*responseData);
- this->advanceClocks(time::milliseconds(1));
+ this->advanceClocks(1_ms);
scenario.checkCommandOutcome(this);
}
@@ -236,13 +236,13 @@
BOOST_CHECK_EQUAL(dest.isAvailable(), false);
rib.insert(commandPrefix, route);
- this->advanceClocks(time::milliseconds(100));
+ this->advanceClocks(100_ms);
BOOST_CHECK_EQUAL(dest.isAvailable(), true);
BOOST_REQUIRE_EQUAL(availabilityChangeHistory.size(), 1);
BOOST_CHECK_EQUAL(availabilityChangeHistory.back(), true);
rib.erase(commandPrefix, route);
- this->advanceClocks(time::milliseconds(100));
+ this->advanceClocks(100_ms);
BOOST_CHECK_EQUAL(dest.isAvailable(), false);
BOOST_REQUIRE_EQUAL(availabilityChangeHistory.size(), 2);
BOOST_CHECK_EQUAL(availabilityChangeHistory.back(), false);
diff --git a/tests/daemon/rib/readvertise/readvertise.t.cpp b/tests/daemon/rib/readvertise/readvertise.t.cpp
index 090bd5a..1988a20 100644
--- a/tests/daemon/rib/readvertise/readvertise.t.cpp
+++ b/tests/daemon/rib/readvertise/readvertise.t.cpp
@@ -133,7 +133,7 @@
route.faceId = faceId;
route.origin = origin;
m_rib.insert(prefix, route);
- this->advanceClocks(time::milliseconds(6));
+ this->advanceClocks(6_ms);
}
void
@@ -143,14 +143,14 @@
route.faceId = faceId;
route.origin = origin;
m_rib.erase(prefix, route);
- this->advanceClocks(time::milliseconds(6));
+ this->advanceClocks(6_ms);
}
void
setDestinationAvailability(bool isAvailable)
{
destination->setAvailability(isAvailable);
- this->advanceClocks(time::milliseconds(6));
+ this->advanceClocks(6_ms);
}
protected:
@@ -181,7 +181,7 @@
// refresh every 60 seconds
destination->advertiseHistory.clear();
- this->advanceClocks(time::seconds(61), 5);
+ this->advanceClocks(61_s, 5);
BOOST_CHECK_EQUAL(destination->advertiseHistory.size(), 5);
// /A is still needed by /A/2 route
@@ -244,7 +244,7 @@
policy->decision = ReadvertiseAction{"/A", ndn::security::SigningInfo()};
this->insertRoute("/A/1", 1, ndn::nfd::ROUTE_ORIGIN_CLIENT);
- this->advanceClocks(time::seconds(10), time::seconds(3600));
+ this->advanceClocks(10_s, 1_h);
BOOST_REQUIRE_GT(destination->advertiseHistory.size(), 2);
// destination->advertise keeps failing, so interval should increase
@@ -260,12 +260,12 @@
}
destination->shouldSucceed = true;
- this->advanceClocks(time::seconds(3600));
+ this->advanceClocks(1_h);
destination->advertiseHistory.clear();
// destination->advertise has succeeded, retry interval should reset to initial
destination->shouldSucceed = false;
- this->advanceClocks(time::seconds(10), time::seconds(300));
+ this->advanceClocks(10_s, 300_s);
BOOST_REQUIRE_GE(destination->advertiseHistory.size(), 2);
FloatInterval restartInterval = destination->advertiseHistory[1].timestamp -
destination->advertiseHistory[0].timestamp;
@@ -277,7 +277,7 @@
destination->shouldSucceed = false;
policy->decision = ReadvertiseAction{"/A", ndn::security::SigningInfo()};
this->insertRoute("/A/1", 1, ndn::nfd::ROUTE_ORIGIN_CLIENT);
- this->advanceClocks(time::seconds(10), time::seconds(300));
+ this->advanceClocks(10_s, 300_s);
BOOST_CHECK_GT(destination->advertiseHistory.size(), 0);
BOOST_CHECK_EQUAL(destination->withdrawHistory.size(), 0);
@@ -285,7 +285,7 @@
destination->advertiseHistory.clear();
destination->withdrawHistory.clear();
this->eraseRoute("/A/1", 1, ndn::nfd::ROUTE_ORIGIN_CLIENT);
- this->advanceClocks(time::seconds(10), time::seconds(300));
+ this->advanceClocks(10_s, 300_s);
BOOST_CHECK_EQUAL(destination->advertiseHistory.size(), 0); // don't try to advertise
BOOST_CHECK_GT(destination->withdrawHistory.size(), 0); // try to withdraw
@@ -293,7 +293,7 @@
destination->advertiseHistory.clear();
destination->withdrawHistory.clear();
this->insertRoute("/A/1", 1, ndn::nfd::ROUTE_ORIGIN_CLIENT);
- this->advanceClocks(time::seconds(10), time::seconds(300));
+ this->advanceClocks(10_s, 300_s);
BOOST_CHECK_GT(destination->advertiseHistory.size(), 0); // try to advertise
BOOST_CHECK_EQUAL(destination->withdrawHistory.size(), 0); // don't try to withdraw
}
diff --git a/tests/daemon/rib/rib-update.t.cpp b/tests/daemon/rib/rib-update.t.cpp
index a4feca1..81ee10e 100644
--- a/tests/daemon/rib/rib-update.t.cpp
+++ b/tests/daemon/rib/rib-update.t.cpp
@@ -34,7 +34,9 @@
namespace rib {
namespace tests {
-BOOST_FIXTURE_TEST_SUITE(TestRibUpdate, nfd::tests::GlobalIoFixture)
+using namespace nfd::tests;
+
+BOOST_FIXTURE_TEST_SUITE(TestRibUpdate, GlobalIoFixture)
BOOST_AUTO_TEST_CASE(BatchBasic)
{
diff --git a/tests/daemon/rib/rib.t.cpp b/tests/daemon/rib/rib.t.cpp
index a1b8363..7de4ebe 100644
--- a/tests/daemon/rib/rib.t.cpp
+++ b/tests/daemon/rib/rib.t.cpp
@@ -33,7 +33,9 @@
namespace rib {
namespace tests {
-BOOST_FIXTURE_TEST_SUITE(TestRib, nfd::tests::GlobalIoFixture)
+using namespace nfd::tests;
+
+BOOST_FIXTURE_TEST_SUITE(TestRib, GlobalIoFixture)
BOOST_AUTO_TEST_CASE(Parent)
{
@@ -170,7 +172,7 @@
route1.faceId = 1;
route1.cost = 10;
route1.flags = ndn::nfd::ROUTE_FLAG_CHILD_INHERIT | ndn::nfd::ROUTE_FLAG_CAPTURE;
- route1.expires = time::steady_clock::now() + time::milliseconds(1500);
+ route1.expires = time::steady_clock::now() + 1500_ms;
rib.insert(name1, route1);
BOOST_CHECK_EQUAL(rib.size(), 1);
@@ -183,7 +185,7 @@
route2.faceId = 1;
route2.cost = 100;
route2.flags = ndn::nfd::ROUTE_FLAG_CHILD_INHERIT;
- route2.expires = time::steady_clock::now() + time::seconds(0);
+ route2.expires = time::steady_clock::now() + 0_s;
rib.insert(name2, route2);
BOOST_CHECK_EQUAL(rib.size(), 1);
diff --git a/tests/daemon/rib/service.t.cpp b/tests/daemon/rib/service.t.cpp
index 156257b..e732e07 100644
--- a/tests/daemon/rib/service.t.cpp
+++ b/tests/daemon/rib/service.t.cpp
@@ -33,7 +33,9 @@
namespace rib {
namespace tests {
-BOOST_FIXTURE_TEST_SUITE(TestService, nfd::tests::RibIoFixture)
+using namespace nfd::tests;
+
+BOOST_FIXTURE_TEST_SUITE(TestService, RibIoFixture)
BOOST_AUTO_TEST_CASE(Basic)
{