tests+tools: minor code cleanup
Change-Id: Ic3356d4a18a8e5eeb45fc076fc0563c3d1549c8a
diff --git a/tests/daemon/fw/access-strategy.t.cpp b/tests/daemon/fw/access-strategy.t.cpp
index d950fc2..afa73b6 100644
--- a/tests/daemon/fw/access-strategy.t.cpp
+++ b/tests/daemon/fw/access-strategy.t.cpp
@@ -32,10 +32,8 @@
namespace fw {
namespace tests {
-using namespace nfd::tests;
-
// The tester is unused in this file, but it's used in various templated test suites.
-typedef StrategyTester<AccessStrategy> AccessStrategyTester;
+using AccessStrategyTester = StrategyTester<AccessStrategy>;
NFD_REGISTER_STRATEGY(AccessStrategyTester);
// This test suite tests AccessStrategy's behavior as a black box,
@@ -73,8 +71,8 @@
topo.setStrategy<fw::AccessStrategy>(router);
- linkA = topo.addLink("RA", time::milliseconds(10), {router, laptopA});
- linkB = topo.addLink("RB", time::milliseconds(20), {router, laptopB});
+ linkA = topo.addLink("RA", 10_ms, {router, laptopA});
+ linkB = topo.addLink("RB", 20_ms, {router, laptopB});
}
protected:
@@ -124,10 +122,9 @@
topo.addEchoProducer(producer->getClientFace());
shared_ptr<TopologyAppLink> consumer = topo.addAppFace("c", router);
- topo.addIntervalConsumer(consumer->getClientFace(), "ndn:/laptops/A",
- time::milliseconds(100), 100);
+ topo.addIntervalConsumer(consumer->getClientFace(), "ndn:/laptops/A", 100_ms, 100);
- this->advanceClocks(time::milliseconds(5), time::seconds(12));
+ this->advanceClocks(5_ms, 12_s);
// most Interests should be satisfied, and few Interests can go to wrong laptop
BOOST_CHECK_GE(consumer->getForwarderFace().getCounters().nOutData, 97);
@@ -171,10 +168,9 @@
topo.addEchoProducer(producerB->getClientFace());
shared_ptr<TopologyAppLink> consumer = topo.addAppFace("c", router);
- topo.addIntervalConsumer(consumer->getClientFace(), "ndn:/laptops/BOTH",
- time::milliseconds(100), 100);
+ topo.addIntervalConsumer(consumer->getClientFace(), "ndn:/laptops/BOTH", 100_ms, 100);
- this->advanceClocks(time::milliseconds(5), time::seconds(12));
+ this->advanceClocks(5_ms, 12_s);
// most Interests should be satisfied, and few Interests can go to slower laptopB
BOOST_CHECK_GE(consumer->getForwarderFace().getCounters().nOutData, 97);
@@ -218,12 +214,11 @@
topo.addEchoProducer(producerB->getClientFace());
shared_ptr<TopologyAppLink> consumer = topo.addAppFace("c", router);
- topo.addIntervalConsumer(consumer->getClientFace(), "ndn:/laptops/M",
- time::milliseconds(100), 100);
+ topo.addIntervalConsumer(consumer->getClientFace(), "ndn:/laptops/M", 100_ms, 100);
// producer is initially on laptopA
producerB->fail();
- this->advanceClocks(time::milliseconds(5), time::seconds(6));
+ this->advanceClocks(5_ms, 6_s);
// few Interests can go to laptopB
BOOST_CHECK_LE(linkB->getFace(router).getCounters().nOutInterests, 5);
@@ -232,7 +227,7 @@
producerA->fail();
producerB->recover();
PacketCounter::rep nInterestsToA_beforeMove = linkA->getFace(router).getCounters().nOutInterests;
- this->advanceClocks(time::milliseconds(5), time::seconds(6));
+ this->advanceClocks(5_ms, 6_s);
// few additional Interests can go to laptopA
BOOST_CHECK_LE(linkA->getFace(router).getCounters().nOutInterests - nInterestsToA_beforeMove, 5);
@@ -274,13 +269,11 @@
topo.addEchoProducer(producerB->getClientFace());
shared_ptr<TopologyAppLink> consumerAB = topo.addAppFace("cAB", laptopA);
- topo.addIntervalConsumer(consumerAB->getClientFace(), "ndn:/laptops/B",
- time::milliseconds(100), 100);
+ topo.addIntervalConsumer(consumerAB->getClientFace(), "ndn:/laptops/B", 100_ms, 100);
shared_ptr<TopologyAppLink> consumerBA = topo.addAppFace("cBA", laptopB);
- topo.addIntervalConsumer(consumerBA->getClientFace(), "ndn:/laptops/A",
- time::milliseconds(100), 100);
+ topo.addIntervalConsumer(consumerBA->getClientFace(), "ndn:/laptops/A", 100_ms, 100);
- this->advanceClocks(time::milliseconds(5), time::seconds(12));
+ this->advanceClocks(5_ms, 12_s);
// most Interests should be satisfied
BOOST_CHECK_GE(consumerAB->getForwarderFace().getCounters().nOutData, 97);
@@ -324,7 +317,7 @@
consumer->getClientFace().expressInterest(*interest1,
bind([&hasData1] { hasData1 = true; }),
nullptr, nullptr);
- this->advanceClocks(time::milliseconds(5), time::seconds(1));
+ this->advanceClocks(5_ms, 1_s);
BOOST_CHECK_EQUAL(hasData1, true);
// Interest 2 experiences a packet loss on initial transmission
@@ -335,7 +328,7 @@
nullptr,
bind([&hasTimeout2a] { hasTimeout2a = true; }));
producerA->fail();
- this->advanceClocks(time::milliseconds(5), time::milliseconds(60));
+ this->advanceClocks(5_ms, 60_ms);
BOOST_CHECK_EQUAL(hasData2a, false);
BOOST_CHECK_EQUAL(hasTimeout2a, false);
@@ -346,7 +339,7 @@
bind([&hasData2b] { hasData2b = true; }),
nullptr, nullptr);
producerA->recover();
- this->advanceClocks(time::milliseconds(5), time::seconds(1));
+ this->advanceClocks(5_ms, 1_s);
BOOST_CHECK_EQUAL(hasData2b, false);
// Interest 2 retransmission gets through, and is answered
@@ -355,7 +348,7 @@
consumer->getClientFace().expressInterest(*interest2c,
bind([&hasData2c] { hasData2c = true; }),
nullptr, nullptr);
- this->advanceClocks(time::milliseconds(5), time::seconds(1));
+ this->advanceClocks(5_ms, 1_s);
BOOST_CHECK_EQUAL(hasData2c, true);
}
@@ -367,10 +360,9 @@
// send Interests from laptopA to router
shared_ptr<TopologyAppLink> consumer = topo.addAppFace("c", laptopA);
- topo.addIntervalConsumer(consumer->getClientFace(), "ndn:/net",
- time::milliseconds(100), 10);
+ topo.addIntervalConsumer(consumer->getClientFace(), "ndn:/net", 100_ms, 10);
- this->advanceClocks(time::milliseconds(5), time::seconds(2));
+ this->advanceClocks(5_ms, 2_s);
// Interest shouldn't loop back from router
BOOST_CHECK_EQUAL(linkA->getFace(router).getCounters().nOutInterests, 0);
diff --git a/tests/daemon/fw/ad-hoc-forwarding.t.cpp b/tests/daemon/fw/ad-hoc-forwarding.t.cpp
index 5ef50cf..7ec07c7 100644
--- a/tests/daemon/fw/ad-hoc-forwarding.t.cpp
+++ b/tests/daemon/fw/ad-hoc-forwarding.t.cpp
@@ -42,8 +42,6 @@
namespace fw {
namespace tests {
-using namespace nfd::tests;
-
template<typename S>
class AdHocForwardingFixture : public GlobalIoTimeFixture
{
@@ -58,7 +56,7 @@
topo.setStrategy<S>(node);
}
- auto wireless = topo.addLink("ABC", time::milliseconds(10), {nodeA, nodeB, nodeC},
+ auto wireless = topo.addLink("ABC", 10_ms, {nodeA, nodeB, nodeC},
ndn::nfd::LINK_TYPE_AD_HOC);
wireless->block(nodeA, nodeC);
wireless->block(nodeC, nodeA);
@@ -103,8 +101,8 @@
// B should relay Interest/Data between A and C.
this->topo.registerPrefix(this->nodeB, *this->faceB, "/P");
- this->topo.addIntervalConsumer(this->appA->getClientFace(), "/P", time::milliseconds(100), 10);
- this->advanceClocks(time::milliseconds(5), time::milliseconds(1200));
+ this->topo.addIntervalConsumer(this->appA->getClientFace(), "/P", 100_ms, 10);
+ this->advanceClocks(5_ms, 1200_ms);
// Consumer should receive Data, and B should be relaying.
BOOST_CHECK_EQUAL(this->faceB->getCounters().nInInterests, 10);
@@ -127,17 +125,17 @@
// B's first nexthop is D, but B-D link has failed, so B should relay Interest/Data between A and C.
TopologyNode nodeD = this->topo.addForwarder("D");
- shared_ptr<TopologyLink> linkBD = this->topo.addLink("BD", time::milliseconds(5), {this->nodeB, nodeD});
+ shared_ptr<TopologyLink> linkBD = this->topo.addLink("BD", 5_ms, {this->nodeB, nodeD});
this->topo.registerPrefix(this->nodeB, linkBD->getFace(this->nodeB), "/P", 5);
linkBD->fail();
this->topo.registerPrefix(this->nodeB, *this->faceB, "/P", 10);
// Two interval consumers are expressing Interests with same name 40ms apart,
// so that Interests from the second interval consumer are considered retransmission.
- this->topo.addIntervalConsumer(this->appA->getClientFace(), "/P", time::milliseconds(100), 50, 1);
- this->advanceClocks(time::milliseconds(5), time::milliseconds(40));
- this->topo.addIntervalConsumer(this->appA->getClientFace(), "/P", time::milliseconds(100), 50, 1);
- this->advanceClocks(time::milliseconds(5), time::milliseconds(5400));
+ this->topo.addIntervalConsumer(this->appA->getClientFace(), "/P", 100_ms, 50, 1);
+ this->advanceClocks(5_ms, 40_ms);
+ this->topo.addIntervalConsumer(this->appA->getClientFace(), "/P", 100_ms, 50, 1);
+ this->advanceClocks(5_ms, 5400_ms);
// Consumer should receive Data, and B should be relaying at least some Interest/Data.
BOOST_CHECK_GE(this->faceB->getCounters().nInInterests, 50);
diff --git a/tests/daemon/fw/algorithm.t.cpp b/tests/daemon/fw/algorithm.t.cpp
index cb32efc..96284f3 100644
--- a/tests/daemon/fw/algorithm.t.cpp
+++ b/tests/daemon/fw/algorithm.t.cpp
@@ -216,7 +216,7 @@
time::steady_clock::TimePoint before = time::steady_clock::now();
entry.insertOrUpdateOutRecord(*face1, 0, *interest);
- this->advanceClocks(time::milliseconds(1000));
+ this->advanceClocks(1_s);
BOOST_CHECK_EQUAL(getLastOutgoing(entry), before);
diff --git a/tests/daemon/fw/asf-measurements.t.cpp b/tests/daemon/fw/asf-measurements.t.cpp
index a5fee3f..d08f761 100644
--- a/tests/daemon/fw/asf-measurements.t.cpp
+++ b/tests/daemon/fw/asf-measurements.t.cpp
@@ -50,7 +50,7 @@
BOOST_CHECK_EQUAL(stats.getSrtt(), RttStats::RTT_NO_MEASUREMENT);
// Receive Data back in 50ms
- RttEstimator::Duration rtt(time::milliseconds(50));
+ RttEstimator::Duration rtt(50_ms);
stats.addRttMeasurement(rtt);
BOOST_CHECK_EQUAL(stats.getRtt(), rtt);
@@ -63,7 +63,7 @@
BOOST_CHECK_EQUAL(stats.getSrtt(), rtt);
// Receive Data back with a higher RTT
- RttEstimator::Duration higherRtt(time::milliseconds(100));
+ RttEstimator::Duration higherRtt(100_ms);
stats.addRttMeasurement(higherRtt);
BOOST_CHECK_EQUAL(stats.getRtt(), higherRtt);
@@ -105,7 +105,7 @@
pitEntry->insertOrUpdateOutRecord(*face, 0, *interest);
RttEstimator::Duration rtt(50);
- this->advanceClocks(time::milliseconds(5), rtt);
+ this->advanceClocks(5_ms, rtt);
info.recordRtt(pitEntry, *face);
info.cancelTimeoutEvent(interestName);
diff --git a/tests/daemon/fw/asf-strategy.t.cpp b/tests/daemon/fw/asf-strategy.t.cpp
index d363880..27ed2aa 100644
--- a/tests/daemon/fw/asf-strategy.t.cpp
+++ b/tests/daemon/fw/asf-strategy.t.cpp
@@ -36,7 +36,7 @@
using namespace nfd::fw::tests;
// The tester is unused in this file, but it's used in various templated test suites.
-typedef StrategyTester<AsfStrategy> AsfStrategyTester;
+using AsfStrategyTester = StrategyTester<AsfStrategy>;
NFD_REGISTER_STRATEGY(AsfStrategyTester);
BOOST_AUTO_TEST_SUITE(Fw)
@@ -45,8 +45,9 @@
class AsfGridFixture : public GlobalIoTimeFixture
{
protected:
- AsfGridFixture(Name parameters = AsfStrategy::getStrategyName())
- : parameters(parameters)
+ explicit
+ AsfGridFixture(const Name& params = AsfStrategy::getStrategyName())
+ : parameters(params)
{
/*
* +---------+
@@ -74,10 +75,10 @@
topo.setStrategy<AsfStrategy>(nodeC, Name("ndn:/"), parameters);
topo.setStrategy<AsfStrategy>(nodeD, Name("ndn:/"), parameters);
- linkAB = topo.addLink("AB", time::milliseconds(10), {nodeA, nodeB});
- linkAD = topo.addLink("AD", time::milliseconds(100), {nodeA, nodeD});
- linkBC = topo.addLink("BC", time::milliseconds(10), {nodeB, nodeC});
- linkCD = topo.addLink("CD", time::milliseconds(100), {nodeC, nodeD});
+ linkAB = topo.addLink("AB", 10_ms, {nodeA, nodeB});
+ linkAD = topo.addLink("AD", 100_ms, {nodeA, nodeD});
+ linkBC = topo.addLink("BC", 10_ms, {nodeB, nodeC});
+ linkCD = topo.addLink("CD", 100_ms, {nodeC, nodeD});
consumer = topo.addAppFace("c", nodeA);
producer = topo.addAppFace("p", nodeC, PRODUCER_PREFIX);
@@ -91,8 +92,8 @@
void
runConsumer(int numInterests = 30)
{
- topo.addIntervalConsumer(consumer->getClientFace(), PRODUCER_PREFIX, time::seconds(1), numInterests);
- this->advanceClocks(time::milliseconds(10), time::seconds(numInterests));
+ topo.addIntervalConsumer(consumer->getClientFace(), PRODUCER_PREFIX, 1_s, numInterests);
+ this->advanceClocks(10_ms, time::seconds(numInterests));
}
protected:
@@ -160,7 +161,7 @@
linkAB->recover();
// Advance time to ensure probing is due
- this->advanceClocks(time::milliseconds(10), time::seconds(10));
+ this->advanceClocks(10_ms, 10_s);
runConsumer();
@@ -229,10 +230,10 @@
topo.setStrategy<AsfStrategy>(node);
}
- shared_ptr<TopologyLink> linkAB = topo.addLink("AB", time::milliseconds(15), {nodeA, nodeB}),
- linkAC = topo.addLink("AC", time::milliseconds(14), {nodeA, nodeC}),
- linkBC = topo.addLink("BC", time::milliseconds(16), {nodeB, nodeC}),
- linkBD = topo.addLink("BD", time::milliseconds(80), {nodeB, nodeD});
+ shared_ptr<TopologyLink> linkAB = topo.addLink("AB", 15_ms, {nodeA, nodeB}),
+ linkAC = topo.addLink("AC", 14_ms, {nodeA, nodeC}),
+ linkBC = topo.addLink("BC", 16_ms, {nodeB, nodeC}),
+ linkBD = topo.addLink("BD", 80_ms, {nodeB, nodeD});
shared_ptr<TopologyAppLink> ping = topo.addAppFace("c", nodeA),
pingServer = topo.addAppFace("p", nodeD, PRODUCER_PREFIX);
@@ -257,14 +258,8 @@
// Don't know when the probe will be triggered since it is random between 0-5 seconds
// or whether it will be triggered for this interest
- int j = 1;
- while (linkAB->getFace(nodeA).getCounters().nOutInterests != 1) {
- this->advanceClocks(time::milliseconds(1));
- ++j;
- // Probe was not scheduled with this ping interest
- if (j > 1000) {
- break;
- }
+ for (int j = 1; j <= 1000 && linkAB->getFace(nodeA).getCounters().nOutInterests != 1; ++j) {
+ this->advanceClocks(1_ms);
}
// Check if probe is sent to B else send another ping
@@ -286,7 +281,7 @@
BOOST_CHECK_EQUAL(linkBD->getFace(nodeB).getCounters().nOutInterests, i - 1);
// After 15ms, B should get the probe interest
- this->advanceClocks(time::milliseconds(1), time::milliseconds(15));
+ this->advanceClocks(1_ms, 15_ms);
BOOST_CHECK_EQUAL(linkAB->getFace(nodeB).getCounters().nInInterests, 1);
BOOST_CHECK_EQUAL(linkBD->getFace(nodeB).getCounters().nOutInterests, i);
@@ -298,7 +293,7 @@
BOOST_CHECK(outRecord != pitEntry->out_end());
// RTT between B and D
- this->advanceClocks(time::milliseconds(5), time::milliseconds(160));
+ this->advanceClocks(5_ms, 160_ms);
outRecord = pitEntry->getOutRecord(linkBD->getFace(nodeB), 0);
BOOST_CHECK_EQUAL(linkBD->getFace(nodeB).getCounters().nInData, i);
@@ -308,7 +303,7 @@
// Data is returned for the ping after 15 ms - will result in false measurement
// 14+16-15 = 15ms
// Since outRecord == pitEntry->out_end()
- this->advanceClocks(time::milliseconds(1), time::milliseconds(15));
+ this->advanceClocks(1_ms, 15_ms);
BOOST_CHECK_EQUAL(linkBD->getFace(nodeB).getCounters().nInData, i+1);
break;
@@ -352,7 +347,7 @@
// Send 6 interests let it change to use the 10 ms link
runConsumer(6);
- shared_ptr<TopologyLink> linkAC = topo.addLink("AC", time::milliseconds(5), {nodeA, nodeD});
+ shared_ptr<TopologyLink> linkAC = topo.addLink("AC", 5_ms, {nodeA, nodeD});
topo.registerPrefix(nodeA, linkAC->getFace(nodeA), PRODUCER_PREFIX, 1);
BOOST_CHECK_EQUAL(linkAC->getFace(nodeA).getCounters().nOutInterests, 0);
diff --git a/tests/daemon/fw/best-route-strategy.t.cpp b/tests/daemon/fw/best-route-strategy.t.cpp
index 7a2db75..b11cdae 100644
--- a/tests/daemon/fw/best-route-strategy.t.cpp
+++ b/tests/daemon/fw/best-route-strategy.t.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
- * Copyright (c) 2014-2016, Regents of the University of California,
+/*
+ * Copyright (c) 2014-2019, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -32,10 +32,8 @@
namespace fw {
namespace tests {
-using namespace nfd::tests;
-
// The tester is unused in this file, but it's used in various templated test suites.
-typedef StrategyTester<BestRouteStrategy> BestRouteStrategyTester;
+using BestRouteStrategyTester = StrategyTester<BestRouteStrategy>;
NFD_REGISTER_STRATEGY(BestRouteStrategyTester);
} // namespace tests
diff --git a/tests/daemon/fw/best-route-strategy2.t.cpp b/tests/daemon/fw/best-route-strategy2.t.cpp
index 4101464..5776f6c 100644
--- a/tests/daemon/fw/best-route-strategy2.t.cpp
+++ b/tests/daemon/fw/best-route-strategy2.t.cpp
@@ -34,9 +34,7 @@
namespace fw {
namespace tests {
-using namespace nfd::tests;
-
-typedef StrategyTester<BestRouteStrategy2> BestRouteStrategy2Tester;
+using BestRouteStrategy2Tester = StrategyTester<BestRouteStrategy2>;
NFD_REGISTER_STRATEGY(BestRouteStrategy2Tester);
BOOST_AUTO_TEST_SUITE(Fw)
diff --git a/tests/daemon/fw/forwarder.t.cpp b/tests/daemon/fw/forwarder.t.cpp
index 8e3bae3..59b5ef3 100644
--- a/tests/daemon/fw/forwarder.t.cpp
+++ b/tests/daemon/fw/forwarder.t.cpp
@@ -45,7 +45,7 @@
Forwarder forwarder;
shared_ptr<Interest> interestAB = makeInterest("/A/B");
- interestAB->setInterestLifetime(time::seconds(4));
+ interestAB->setInterestLifetime(4_s);
shared_ptr<Data> dataABC = makeData("/A/B/C");
auto face1 = make_shared<DummyFace>();
@@ -61,7 +61,7 @@
BOOST_CHECK_EQUAL(forwarder.getCounters().nCsHits, 0);
BOOST_CHECK_EQUAL(forwarder.getCounters().nCsMisses, 0);
face1->receiveInterest(*interestAB);
- this->advanceClocks(time::milliseconds(100), time::seconds(1));
+ this->advanceClocks(100_ms, 1_s);
BOOST_REQUIRE_EQUAL(face2->sentInterests.size(), 1);
BOOST_CHECK_EQUAL(face2->sentInterests[0].getName(), "/A/B");
BOOST_REQUIRE(face2->sentInterests[0].getTag<lp::IncomingFaceIdTag>() != nullptr);
@@ -74,7 +74,7 @@
BOOST_CHECK_EQUAL(forwarder.getCounters().nInData, 0);
BOOST_CHECK_EQUAL(forwarder.getCounters().nOutData, 0);
face2->receiveData(*dataABC);
- this->advanceClocks(time::milliseconds(100), time::seconds(1));
+ this->advanceClocks(100_ms, 1_s);
BOOST_REQUIRE_EQUAL(face1->sentData.size(), 1);
BOOST_CHECK_EQUAL(face1->sentData[0].getName(), "/A/B/C");
BOOST_REQUIRE(face1->sentData[0].getTag<lp::IncomingFaceIdTag>() != nullptr);
@@ -95,7 +95,7 @@
forwarder.addFace(face3);
shared_ptr<Interest> interestA = makeInterest("/A");
- interestA->setInterestLifetime(time::seconds(4));
+ interestA->setInterestLifetime(4_s);
shared_ptr<Data> dataA = makeData("/A");
dataA->setTag(make_shared<lp::IncomingFaceIdTag>(face3->getId()));
@@ -111,7 +111,7 @@
BOOST_CHECK_EQUAL(forwarder.getCounters().nCsHits, 0);
BOOST_CHECK_EQUAL(forwarder.getCounters().nCsMisses, 0);
face1->receiveInterest(*interestA);
- this->advanceClocks(time::milliseconds(1), time::milliseconds(5));
+ this->advanceClocks(1_ms, 5_ms);
// Interest matching ContentStore should not be forwarded
BOOST_REQUIRE_EQUAL(face2->sentInterests.size(), 0);
BOOST_CHECK_EQUAL(forwarder.getCounters().nCsHits, 1);
@@ -122,7 +122,7 @@
BOOST_REQUIRE(face1->sentData[0].getTag<lp::IncomingFaceIdTag>() != nullptr);
BOOST_CHECK_EQUAL(*face1->sentData[0].getTag<lp::IncomingFaceIdTag>(), face::FACEID_CONTENT_STORE);
- this->advanceClocks(time::milliseconds(100), time::milliseconds(500));
+ this->advanceClocks(100_ms, 500_ms);
// PIT entry should not be left behind
BOOST_CHECK_EQUAL(pit.size(), 0);
}
@@ -171,7 +171,7 @@
interest->setTag(make_shared<lp::NextHopFaceIdTag>(face2->getId()));
face1->receiveInterest(*interest);
- this->advanceClocks(time::milliseconds(100), time::seconds(1));
+ this->advanceClocks(100_ms, 1_s);
BOOST_CHECK_EQUAL(face3->sentInterests.size(), 0);
BOOST_REQUIRE_EQUAL(face2->sentInterests.size(), 1);
BOOST_CHECK_EQUAL(face2->sentInterests.front().getName(), "/A/B");
@@ -282,7 +282,7 @@
forwarder.startProcessInterest(FaceEndpoint(*face1, 0), *interest2);
BOOST_CHECK_EQUAL(strategyB.afterReceiveInterest_count, 1);
- this->advanceClocks(time::milliseconds(1), time::milliseconds(5));
+ this->advanceClocks(1_ms, 5_ms);
shared_ptr<Data> data1 = makeData("ndn:/A/1/a");
strategyA.beforeSatisfyInterest_count = 0;
@@ -295,10 +295,10 @@
BOOST_CHECK_EQUAL(strategyB.beforeSatisfyInterest_count, 1);
shared_ptr<Interest> interest3 = makeInterest("ndn:/A/3");
- interest3->setInterestLifetime(time::milliseconds(30));
+ interest3->setInterestLifetime(30_ms);
forwarder.startProcessInterest(FaceEndpoint(*face1, 0), *interest3);
shared_ptr<Interest> interest4 = makeInterest("ndn:/B/4");
- interest4->setInterestLifetime(time::milliseconds(5000));
+ interest4->setInterestLifetime(5_s);
forwarder.startProcessInterest(FaceEndpoint(*face1, 0), *interest4);
}
@@ -329,7 +329,7 @@
shared_ptr<Data> dataD = makeData("ndn:/A/B/C/D");
forwarder.onIncomingData(FaceEndpoint(*face3, 0), *dataD);
- this->advanceClocks(time::milliseconds(1), time::milliseconds(5));
+ this->advanceClocks(1_ms, 5_ms);
BOOST_CHECK_EQUAL(face1->sentData.size(), 1);
BOOST_CHECK_EQUAL(face2->sentData.size(), 1);
@@ -557,12 +557,12 @@
// receive an Interest
shared_ptr<Interest> interest = makeInterest("ndn:/A/1");
interest->setNonce(82101183);
- interest->setInterestLifetime(time::milliseconds(50));
+ interest->setInterestLifetime(50_ms);
face1->receiveInterest(*interest);
// interest should be forwarded only once, as long as Nonce is in Dead Nonce List
- BOOST_ASSERT(time::milliseconds(25) * 40 < forwarder.getDeadNonceList().getLifetime());
- this->advanceClocks(time::milliseconds(25), 40);
+ BOOST_ASSERT(25_ms * 40 < forwarder.getDeadNonceList().getLifetime());
+ this->advanceClocks(25_ms, 40);
BOOST_CHECK_EQUAL(face2->sentInterests.size(), 1);
@@ -581,7 +581,7 @@
shared_ptr<Interest> interest = makeInterest("ndn:/hcLSAsQ9A");
interest->setNonce(61883075);
- interest->setInterestLifetime(time::seconds(2));
+ interest->setInterestLifetime(2_s);
DeadNonceList& dnl = forwarder.getDeadNonceList();
dnl.add(interest->getName(), interest->getNonce());
@@ -589,7 +589,7 @@
BOOST_REQUIRE_EQUAL(pit.size(), 0);
forwarder.startProcessInterest(FaceEndpoint(*face1, 0), *interest);
- this->advanceClocks(time::milliseconds(100), time::seconds(20));
+ this->advanceClocks(100_ms, 20_s);
BOOST_CHECK_EQUAL(pit.size(), 0);
}
diff --git a/tests/daemon/fw/forwarding-hint.t.cpp b/tests/daemon/fw/forwarding-hint.t.cpp
index e37c267..7e9dbdc 100644
--- a/tests/daemon/fw/forwarding-hint.t.cpp
+++ b/tests/daemon/fw/forwarding-hint.t.cpp
@@ -77,12 +77,12 @@
topo.getForwarder(nodeS).getNetworkRegionTable().insert("/ucla/cs/spurs");
// NetworkRegionTable configuration is unnecessary on end hosts
- linkAH = topo.addLink("AH", time::milliseconds(10), {nodeA, nodeH});
- linkHT = topo.addLink("HT", time::milliseconds(10), {nodeH, nodeT});
- linkTP = topo.addLink("TP", time::milliseconds(10), {nodeT, nodeP});
- linkHC = topo.addLink("HC", time::milliseconds(10), {nodeH, nodeC});
- linkCS = topo.addLink("CS", time::milliseconds(10), {nodeC, nodeS});
- linkSQ = topo.addLink("SQ", time::milliseconds(10), {nodeS, nodeQ});
+ linkAH = topo.addLink("AH", 10_ms, {nodeA, nodeH});
+ linkHT = topo.addLink("HT", 10_ms, {nodeH, nodeT});
+ linkTP = topo.addLink("TP", 10_ms, {nodeT, nodeP});
+ linkHC = topo.addLink("HC", 10_ms, {nodeH, nodeC});
+ linkCS = topo.addLink("CS", 10_ms, {nodeC, nodeS});
+ linkSQ = topo.addLink("SQ", 10_ms, {nodeS, nodeQ});
consumerA = topo.addAppFace("avenir", nodeA);
producerP = topo.addAppFace("ndnsimP", nodeP, "/net/ndnsim");
producerQ = topo.addAppFace("ndnsimQ", nodeQ, "/net/ndnsim");
@@ -123,7 +123,7 @@
BOOST_AUTO_TEST_CASE(FetchTelia)
{
this->consumerExpressInterest(1);
- this->advanceClocks(time::milliseconds(11), 20);
+ this->advanceClocks(11_ms, 20);
// A forwards Interest according to default route, no change to forwarding hint
BOOST_CHECK_EQUAL(linkAH->getFace(nodeA).getCounters().nOutInterests, 1);
@@ -152,7 +152,7 @@
topo.getForwarder(nodeH).getFib().erase("/telia");
this->consumerExpressInterest(1);
- this->advanceClocks(time::milliseconds(11), 20);
+ this->advanceClocks(11_ms, 20);
// A forwards Interest according to default route, no change to forwarding hint
BOOST_CHECK_EQUAL(linkAH->getFace(nodeA).getCounters().nOutInterests, 1);
diff --git a/tests/daemon/fw/multicast-strategy.t.cpp b/tests/daemon/fw/multicast-strategy.t.cpp
index a6d9be6..e1c4027 100644
--- a/tests/daemon/fw/multicast-strategy.t.cpp
+++ b/tests/daemon/fw/multicast-strategy.t.cpp
@@ -34,9 +34,7 @@
namespace fw {
namespace tests {
-using namespace nfd::tests;
-
-typedef StrategyTester<MulticastStrategy> MulticastStrategyTester;
+using MulticastStrategyTester = StrategyTester<MulticastStrategy>;
NFD_REGISTER_STRATEGY(MulticastStrategyTester);
class MulticastStrategyFixture : public GlobalIoTimeFixture
diff --git a/tests/daemon/fw/ncc-strategy.t.cpp b/tests/daemon/fw/ncc-strategy.t.cpp
index 86238af..d7172e3 100644
--- a/tests/daemon/fw/ncc-strategy.t.cpp
+++ b/tests/daemon/fw/ncc-strategy.t.cpp
@@ -33,9 +33,7 @@
namespace fw {
namespace tests {
-using namespace nfd::tests;
-
-typedef StrategyTester<NccStrategy> NccStrategyTester;
+using NccStrategyTester = StrategyTester<NccStrategy>;
NFD_REGISTER_STRATEGY(NccStrategyTester);
BOOST_AUTO_TEST_SUITE(Fw)
@@ -69,7 +67,7 @@
// first Interest: strategy knows nothing and follows routing
shared_ptr<Interest> interest1p = makeInterest("ndn:/0Jm1ajrW/%00");
Interest& interest1 = *interest1p;
- interest1.setInterestLifetime(time::milliseconds(8000));
+ interest1.setInterestLifetime(8_s);
shared_ptr<pit::Entry> pitEntry1 = pit.insert(interest1).first;
pitEntry1->insertOrUpdateInRecord(*face3, 0, interest1);
@@ -81,7 +79,7 @@
BOOST_CHECK_EQUAL(strategy.sendInterestHistory[0].outFaceId, face1->getId());
// forwards to face2 because face1 doesn't respond
- limitedIo.run(1, time::milliseconds(500), time::milliseconds(10));
+ limitedIo.run(1, 500_ms, 10_ms);
BOOST_REQUIRE_EQUAL(strategy.sendInterestHistory.size(), 2);
BOOST_CHECK_EQUAL(strategy.sendInterestHistory[1].outFaceId, face2->getId());
@@ -89,19 +87,19 @@
shared_ptr<Data> data1p = makeData("ndn:/0Jm1ajrW/%00");
Data& data1 = *data1p;
strategy.beforeSatisfyInterest(pitEntry1, FaceEndpoint(*face2, 0), data1);
- this->advanceClocks(time::milliseconds(10), time::milliseconds(500));
+ this->advanceClocks(10_ms, 500_ms);
// second Interest: strategy knows face2 is best
shared_ptr<Interest> interest2p = makeInterest("ndn:/0Jm1ajrW/%00%01");
Interest& interest2 = *interest2p;
- interest2.setInterestLifetime(time::milliseconds(8000));
+ interest2.setInterestLifetime(8_s);
shared_ptr<pit::Entry> pitEntry2 = pit.insert(interest2).first;
pitEntry2->insertOrUpdateInRecord(*face3, 0, interest2);
strategy.afterReceiveInterest(FaceEndpoint(*face3, 0), interest2, pitEntry2);
// forwards to face2 because it responds previously
- this->advanceClocks(time::milliseconds(1));
+ this->advanceClocks(1_ms);
BOOST_REQUIRE_GE(strategy.sendInterestHistory.size(), 3);
BOOST_CHECK_EQUAL(strategy.sendInterestHistory[2].outFaceId, face2->getId());
}
@@ -126,25 +124,25 @@
// first Interest: strategy follows routing and forwards to face1
shared_ptr<Interest> interest1 = makeInterest("ndn:/nztwIvHX/%00");
- interest1->setInterestLifetime(time::milliseconds(8000));
+ interest1->setInterestLifetime(8_s);
shared_ptr<pit::Entry> pitEntry1 = pit.insert(*interest1).first;
pitEntry1->insertOrUpdateInRecord(*face3, 0, *interest1);
strategy.afterReceiveInterest(FaceEndpoint(*face3, 0), *interest1, pitEntry1);
- this->advanceClocks(time::milliseconds(1));
+ this->advanceClocks(1_ms);
BOOST_REQUIRE_EQUAL(strategy.sendInterestHistory.size(), 1);
BOOST_CHECK_EQUAL(strategy.sendInterestHistory[0].outFaceId, face1->getId());
// face1 responds
shared_ptr<Data> data1 = makeData("ndn:/nztwIvHX/%00");
strategy.beforeSatisfyInterest(pitEntry1, FaceEndpoint(*face1, 0), *data1);
- this->advanceClocks(time::milliseconds(10), time::milliseconds(500));
+ this->advanceClocks(10_ms, 500_ms);
// second Interest: bestFace is face1, nUpstreams becomes 0,
// therefore pitEntryInfo->maxInterval cannot be calculated from deferRange and nUpstreams
shared_ptr<Interest> interest2 = makeInterest("ndn:/nztwIvHX/%01");
- interest2->setInterestLifetime(time::milliseconds(8000));
+ interest2->setInterestLifetime(8_s);
shared_ptr<pit::Entry> pitEntry2 = pit.insert(*interest2).first;
pitEntry2->insertOrUpdateInRecord(*face3, 0, *interest2);
@@ -152,7 +150,7 @@
// FIB entry is changed before doPropagate executes
fibEntry.addOrUpdateNextHop(*face2, 0, 20);
- this->advanceClocks(time::milliseconds(10), time::milliseconds(1000));// should not crash
+ this->advanceClocks(10_ms, 1_s);// should not crash
}
BOOST_AUTO_TEST_CASE(Bug1961)
@@ -178,13 +176,12 @@
// first Interest: strategy forwards to face1 and face2
shared_ptr<Interest> interest1 = makeInterest("ndn:/seRMz5a6/%00");
- interest1->setInterestLifetime(time::milliseconds(2000));
+ interest1->setInterestLifetime(2_s);
shared_ptr<pit::Entry> pitEntry1 = pit.insert(*interest1).first;
pitEntry1->insertOrUpdateInRecord(*face3, 0, *interest1);
strategy.afterReceiveInterest(FaceEndpoint(*face3, 0), *interest1, pitEntry1);
- limitedIo.run(2 - strategy.sendInterestHistory.size(),
- time::milliseconds(2000), time::milliseconds(10));
+ limitedIo.run(2 - strategy.sendInterestHistory.size(), 2_s, 10_ms);
BOOST_REQUIRE_EQUAL(strategy.sendInterestHistory.size(), 2);
BOOST_CHECK_EQUAL(strategy.sendInterestHistory[0].outFaceId, face1->getId());
BOOST_CHECK_EQUAL(strategy.sendInterestHistory[1].outFaceId, face2->getId());
@@ -193,20 +190,19 @@
shared_ptr<Data> data1 = makeData("ndn:/seRMz5a6/%00");
strategy.beforeSatisfyInterest(pitEntry1, FaceEndpoint(*face1, 0), *data1);
pitEntry1->clearInRecords();
- this->advanceClocks(time::milliseconds(10));
+ this->advanceClocks(10_ms);
// face2 also responds
strategy.beforeSatisfyInterest(pitEntry1, FaceEndpoint(*face2, 0), *data1);
- this->advanceClocks(time::milliseconds(10));
+ this->advanceClocks(10_ms);
// second Interest: bestFace should be face 1
shared_ptr<Interest> interest2 = makeInterest("ndn:/seRMz5a6/%01");
- interest2->setInterestLifetime(time::milliseconds(2000));
+ interest2->setInterestLifetime(2_s);
shared_ptr<pit::Entry> pitEntry2 = pit.insert(*interest2).first;
pitEntry2->insertOrUpdateInRecord(*face3, 0, *interest2);
strategy.afterReceiveInterest(FaceEndpoint(*face3, 0), *interest2, pitEntry2);
- limitedIo.run(3 - strategy.sendInterestHistory.size(),
- time::milliseconds(2000), time::milliseconds(10));
+ limitedIo.run(3 - strategy.sendInterestHistory.size(), 2_s, 10_ms);
BOOST_REQUIRE_GE(strategy.sendInterestHistory.size(), 3);
BOOST_CHECK_EQUAL(strategy.sendInterestHistory[2].outFaceId, face1->getId());
@@ -232,29 +228,27 @@
// first Interest: strategy forwards to face2
shared_ptr<Interest> interest1 = makeInterest("ndn:/M4mBXCsd");
- interest1->setInterestLifetime(time::milliseconds(2000));
+ interest1->setInterestLifetime(2_s);
shared_ptr<pit::Entry> pitEntry1 = pit.insert(*interest1).first;
pitEntry1->insertOrUpdateInRecord(*face1, 0, *interest1);
strategy.afterReceiveInterest(FaceEndpoint(*face1, 0), *interest1, pitEntry1);
- limitedIo.run(1 - strategy.sendInterestHistory.size(),
- time::milliseconds(2000), time::milliseconds(10));
+ limitedIo.run(1 - strategy.sendInterestHistory.size(), 2_s, 10_ms);
BOOST_REQUIRE_EQUAL(strategy.sendInterestHistory.size(), 1);
BOOST_CHECK_EQUAL(strategy.sendInterestHistory[0].outFaceId, face2->getId());
// face2 responds
shared_ptr<Data> data1 = makeData("ndn:/M4mBXCsd");
- data1->setFreshnessPeriod(time::milliseconds(5));
+ data1->setFreshnessPeriod(5_ms);
strategy.beforeSatisfyInterest(pitEntry1, FaceEndpoint(*face2, 0), *data1);
pitEntry1->deleteOutRecord(*face2, 0);
pitEntry1->clearInRecords();
- this->advanceClocks(time::milliseconds(10));
+ this->advanceClocks(10_ms);
// similar Interest: strategy should still forward it
pitEntry1->insertOrUpdateInRecord(*face1, 0, *interest1);
strategy.afterReceiveInterest(FaceEndpoint(*face1, 0), *interest1, pitEntry1);
- limitedIo.run(2 - strategy.sendInterestHistory.size(),
- time::milliseconds(2000), time::milliseconds(10));
+ limitedIo.run(2 - strategy.sendInterestHistory.size(), 2_s, 10_ms);
BOOST_REQUIRE_EQUAL(strategy.sendInterestHistory.size(), 2);
BOOST_CHECK_EQUAL(strategy.sendInterestHistory[1].outFaceId, face2->getId());
}
@@ -323,10 +317,10 @@
topo.setStrategy<NccStrategy>(node);
}
- shared_ptr<TopologyLink> linkAB = topo.addLink("AB", time::milliseconds( 5), {nodeA, nodeB}),
- linkAC = topo.addLink("AC", time::milliseconds( 5), {nodeA, nodeC}),
- linkBD = topo.addLink("BD", time::milliseconds(15), {nodeB, nodeD}),
- linkCD = topo.addLink("CD", time::milliseconds(15), {nodeC, nodeD});
+ shared_ptr<TopologyLink> linkAB = topo.addLink("AB", 5_ms, {nodeA, nodeB}),
+ linkAC = topo.addLink("AC", 5_ms, {nodeA, nodeC}),
+ linkBD = topo.addLink("BD", 15_ms, {nodeB, nodeD}),
+ linkCD = topo.addLink("CD", 15_ms, {nodeC, nodeD});
topo.registerPrefix(nodeA, linkAB->getFace(nodeA), "ndn:/P");
topo.registerPrefix(nodeA, linkAC->getFace(nodeA), "ndn:/P");
@@ -338,7 +332,7 @@
shared_ptr<TopologyAppLink> consumer = topo.addAppFace("consumer", nodeA);
topo.addIntervalConsumer(consumer->getClientFace(), "ndn:/P",
- time::milliseconds(100), 300);
+ 100_ms, 300);
auto getMeInfo = [&] () -> NccStrategy::MeasurementsEntryInfo* {
Measurements& measurements = topo.getForwarder(nodeA).getMeasurements();
@@ -353,7 +347,7 @@
bool isLastPredictionUnder = true;
int nPredictionCrossings = 0;
for (int i = 0; i < 10000; ++i) {
- this->advanceClocks(time::milliseconds(5));
+ this->advanceClocks(5_ms);
auto meInfo = getMeInfo();
if (meInfo == nullptr) {
continue;
@@ -369,7 +363,7 @@
}
}
}
- BOOST_REQUIRE_MESSAGE(isExplorationFinished, "exploration does not finish in 50000ms");
+ BOOST_REQUIRE_MESSAGE(isExplorationFinished, "exploration did not finish within 50s");
// NccStrategy has selected one path as the best.
// When we reduce the RTT of the other path, ideally it should be selected as the best face.
@@ -377,10 +371,10 @@
// See https://redmine.named-data.net/issues/3411#note-4
shared_ptr<Face> bestFace1 = getMeInfo()->bestFace.lock();
if (bestFace1.get() == &linkAB->getFace(nodeA)) {
- linkCD->setDelay(time::milliseconds(5));
+ linkCD->setDelay(5_ms);
}
else if (bestFace1.get() == &linkAC->getFace(nodeA)) {
- linkBD->setDelay(time::milliseconds(5));
+ linkBD->setDelay(5_ms);
}
else {
BOOST_FAIL("unexpected best face");
@@ -388,7 +382,7 @@
bool isNewBestChosen = false;
for (int i = 0; i < 10000; ++i) {
- this->advanceClocks(time::milliseconds(5));
+ this->advanceClocks(5_ms);
auto meInfo = getMeInfo();
if (meInfo == nullptr) {
continue;
diff --git a/tests/daemon/fw/retx-suppression.t.cpp b/tests/daemon/fw/retx-suppression.t.cpp
index a0aab02..de4c206 100644
--- a/tests/daemon/fw/retx-suppression.t.cpp
+++ b/tests/daemon/fw/retx-suppression.t.cpp
@@ -93,7 +93,7 @@
{
Forwarder forwarder;
Pit& pit = forwarder.getPit();
- RetxSuppressionExponential rs(time::milliseconds(10), 3.0, time::milliseconds(100));
+ RetxSuppressionExponential rs(10_ms, 3.0, 100_ms);
shared_ptr<DummyFace> face1 = make_shared<DummyFace>();
shared_ptr<DummyFace> face2 = make_shared<DummyFace>();
@@ -109,12 +109,12 @@
pitEntry->insertOrUpdateOutRecord(*face2, 0, *interest);
// suppression interval is 10ms, until 10ms
- this->advanceClocks(time::milliseconds(5)); // @ 5ms
+ this->advanceClocks(5_ms); // @ 5ms
pitEntry->insertOrUpdateInRecord(*face1, 0, *interest);
BOOST_CHECK(rs.decidePerPitEntry(*pitEntry) == RetxSuppressionResult::SUPPRESS);
// suppression interval is 10ms, until 10ms
- this->advanceClocks(time::milliseconds(6)); // @ 11ms
+ this->advanceClocks(6_ms); // @ 11ms
// note: what happens at *exactly* 10ms does not matter so it's untested,
// because in reality network timing won't be exact:
// incoming Interest is processed either before or after 10ms point
@@ -123,34 +123,34 @@
pitEntry->insertOrUpdateOutRecord(*face2, 0, *interest);
// suppression interval is 30ms, until 41ms
- this->advanceClocks(time::milliseconds(25)); // @ 36ms
+ this->advanceClocks(25_ms); // @ 36ms
pitEntry->insertOrUpdateInRecord(*face1, 0, *interest);
BOOST_CHECK(rs.decidePerPitEntry(*pitEntry) == RetxSuppressionResult::SUPPRESS);
// suppression interval is 30ms, until 41ms
- this->advanceClocks(time::milliseconds(6)); // @ 42ms
+ this->advanceClocks(6_ms); // @ 42ms
pitEntry->insertOrUpdateInRecord(*face1, 0, *interest);
BOOST_CHECK(rs.decidePerPitEntry(*pitEntry) == RetxSuppressionResult::FORWARD);
// strategy decides not to forward, but suppression interval is increased nevertheless
// suppression interval is 90ms, until 101ms
- this->advanceClocks(time::milliseconds(58)); // @ 100ms
+ this->advanceClocks(58_ms); // @ 100ms
pitEntry->insertOrUpdateInRecord(*face1, 0, *interest);
BOOST_CHECK(rs.decidePerPitEntry(*pitEntry) == RetxSuppressionResult::SUPPRESS);
// suppression interval is 90ms, until 101ms
- this->advanceClocks(time::milliseconds(3)); // @ 103ms
+ this->advanceClocks(3_ms); // @ 103ms
pitEntry->insertOrUpdateInRecord(*face1, 0, *interest);
BOOST_CHECK(rs.decidePerPitEntry(*pitEntry) == RetxSuppressionResult::FORWARD);
pitEntry->insertOrUpdateOutRecord(*face2, 0, *interest);
// suppression interval is 100ms, until 203ms
- this->advanceClocks(time::milliseconds(99)); // @ 202ms
+ this->advanceClocks(99_ms); // @ 202ms
pitEntry->insertOrUpdateInRecord(*face1, 0, *interest);
BOOST_CHECK(rs.decidePerPitEntry(*pitEntry) == RetxSuppressionResult::SUPPRESS);
// suppression interval is 100ms, until 203ms
- this->advanceClocks(time::milliseconds(2)); // @ 204ms
+ this->advanceClocks(2_ms); // @ 204ms
pitEntry->insertOrUpdateInRecord(*face1, 0, *interest);
BOOST_CHECK(rs.decidePerPitEntry(*pitEntry) == RetxSuppressionResult::FORWARD);
pitEntry->insertOrUpdateOutRecord(*face2, 0, *interest);
@@ -161,7 +161,7 @@
{
Forwarder forwarder;
Pit& pit = forwarder.getPit();
- RetxSuppressionExponential rs(time::milliseconds(10), 3.0, time::milliseconds(100));
+ RetxSuppressionExponential rs(10_ms, 3.0, 100_ms);
shared_ptr<DummyFace> face1 = make_shared<DummyFace>();
shared_ptr<DummyFace> face2 = make_shared<DummyFace>();
@@ -177,7 +177,7 @@
// Simluate forwarding an interest to face2
pitEntry->insertOrUpdateOutRecord(*face2, 0, *interest);
- this->advanceClocks(time::milliseconds(5)); // @ 5ms
+ this->advanceClocks(5_ms); // @ 5ms
pitEntry->insertOrUpdateInRecord(*face1, 0, *interest);
BOOST_CHECK(rs.decidePerUpstream(*pitEntry, *face2) == RetxSuppressionResult::SUPPRESS);
@@ -186,7 +186,7 @@
pitEntry->insertOrUpdateInRecord(*face2, 0, *interest);
BOOST_CHECK(rs.decidePerUpstream(*pitEntry, *face1) == RetxSuppressionResult::NEW);
- this->advanceClocks(time::milliseconds(6)); // @ 11ms
+ this->advanceClocks(6_ms); // @ 11ms
pitEntry->insertOrUpdateInRecord(*face1, 0, *interest);
BOOST_CHECK(rs.decidePerUpstream(*pitEntry, *face2) == RetxSuppressionResult::FORWARD);
diff --git a/tests/daemon/fw/strategy-nack-return.t.cpp b/tests/daemon/fw/strategy-nack-return.t.cpp
index 2708710..c9a66c2 100644
--- a/tests/daemon/fw/strategy-nack-return.t.cpp
+++ b/tests/daemon/fw/strategy-nack-return.t.cpp
@@ -42,8 +42,6 @@
namespace fw {
namespace tests {
-using namespace nfd::tests;
-
BOOST_AUTO_TEST_SUITE(Fw)
template<typename S>
@@ -168,17 +166,17 @@
fibEntry.addOrUpdateNextHop(*this->face5, 0, 30);
shared_ptr<Interest> interest1 = makeInterest("/sIYw0TXWDj", 115);
- interest1->setInterestLifetime(time::milliseconds(400));
+ interest1->setInterestLifetime(400_ms);
shared_ptr<pit::Entry> pitEntry = this->pit.insert(*interest1).first;
pitEntry->insertOrUpdateInRecord(*this->face1, 0, *interest1);
pitEntry->insertOrUpdateOutRecord(*this->face3, 0, *interest1);
- this->advanceClocks(time::milliseconds(300));
+ this->advanceClocks(300_ms);
shared_ptr<Interest> interest2 = makeInterest("/sIYw0TXWDj", 223);
pitEntry->insertOrUpdateInRecord(*this->face1, 0, *interest2);
pitEntry->insertOrUpdateOutRecord(*this->face4, 0, *interest2);
- this->advanceClocks(time::milliseconds(200)); // face3 has timed out
+ this->advanceClocks(200_ms); // face3 has timed out
lp::Nack nack4 = makeNack("/sIYw0TXWDj", 223, lp::NackReason::CONGESTION);
pitEntry->getOutRecord(*this->face4, 0)->setIncomingNack(nack4);
@@ -257,12 +255,12 @@
ndn::Face& appD = topo.addAppFace("D", nodeD)->getClientFace();
int nNacksA = 0, nNacksD = 0;
- appA.expressInterest(Interest("/P/1"), nullptr, bind([&nNacksA]{ ++nNacksA; }), nullptr);
- appD.expressInterest(Interest("/P/1"), nullptr, bind([&nNacksD]{ ++nNacksD; }), nullptr);
- this->advanceClocks(time::milliseconds(1), time::milliseconds(5));
- appA.expressInterest(Interest("/P/1"), nullptr, bind([&nNacksA]{ ++nNacksA; }), nullptr);
- appD.expressInterest(Interest("/P/1"), nullptr, bind([&nNacksD]{ ++nNacksD; }), nullptr);
- this->advanceClocks(time::milliseconds(1), time::milliseconds(100));
+ appA.expressInterest(Interest("/P/1"), nullptr, bind([&nNacksA] { ++nNacksA; }), nullptr);
+ appD.expressInterest(Interest("/P/1"), nullptr, bind([&nNacksD] { ++nNacksD; }), nullptr);
+ this->advanceClocks(1_ms, 5_ms);
+ appA.expressInterest(Interest("/P/1"), nullptr, bind([&nNacksA] { ++nNacksA; }), nullptr);
+ appD.expressInterest(Interest("/P/1"), nullptr, bind([&nNacksD] { ++nNacksD; }), nullptr);
+ this->advanceClocks(1_ms, 100_ms);
// As long as at least one Nack arrives at each client, strategy behavior is correct.
// Whether both Interests are Nacked is a client face behavior, not strategy behavior.
diff --git a/tests/daemon/fw/strategy-no-route.t.cpp b/tests/daemon/fw/strategy-no-route.t.cpp
index daf3f2a..43c57d0 100644
--- a/tests/daemon/fw/strategy-no-route.t.cpp
+++ b/tests/daemon/fw/strategy-no-route.t.cpp
@@ -46,8 +46,6 @@
namespace fw {
namespace tests {
-using namespace nfd::tests;
-
template<typename S>
class StrategyNoRouteFixture : public GlobalIoTimeFixture
{
diff --git a/tests/daemon/fw/strategy-scope-control.t.cpp b/tests/daemon/fw/strategy-scope-control.t.cpp
index 2980834..4b83e46 100644
--- a/tests/daemon/fw/strategy-scope-control.t.cpp
+++ b/tests/daemon/fw/strategy-scope-control.t.cpp
@@ -47,8 +47,6 @@
namespace fw {
namespace tests {
-using namespace nfd::tests;
-
template<typename S>
class StrategyScopeControlFixture : public GlobalIoTimeFixture
{
diff --git a/tests/daemon/fw/strategy-tester.hpp b/tests/daemon/fw/strategy-tester.hpp
index f2ac93d..3ddf8f6 100644
--- a/tests/daemon/fw/strategy-tester.hpp
+++ b/tests/daemon/fw/strategy-tester.hpp
@@ -34,14 +34,16 @@
namespace fw {
namespace tests {
-/** \brief extends strategy S for unit testing
+using namespace nfd::tests;
+
+/** \brief Extends strategy S for unit testing.
*
- * Actions invoked by S are recorded but not passed to forwarder
+ * Actions invoked by S are recorded but not passed to forwarder.
*
* StrategyTester should be registered into the strategy registry prior to use.
* \code
* // appears in or included by every .cpp MyStrategyTester is used
- * typedef StrategyTester<MyStrategy> MyStrategyTester;
+ * using MyStrategyTester = StrategyTester<MyStrategy>;
*
* // appears in only one .cpp
* NFD_REGISTER_STRATEGY(MyStrategyTester);
@@ -82,9 +84,9 @@
* \note The actions may occur either during f() invocation or afterwards.
* \return whether expected number of actions have occurred
*/
+ template<typename F>
bool
- waitForAction(const std::function<void()>& f,
- nfd::tests::LimitedIo& limitedIo, int nExpectedActions = 1)
+ waitForAction(F&& f, LimitedIo& limitedIo, int nExpectedActions = 1)
{
int nActions = 0;
@@ -99,8 +101,7 @@
// A correctly implemented strategy is required to invoke reject pending Interest action if it
// decides to not forward an Interest. If a test case is stuck in the call below, check that
// rejectPendingInterest is invoked under proper condition.
- return limitedIo.run(nExpectedActions - nActions, nfd::tests::LimitedIo::UNLIMITED_TIME) ==
- nfd::tests::LimitedIo::EXCEED_OPS;
+ return limitedIo.run(nExpectedActions - nActions, LimitedIo::UNLIMITED_TIME) == LimitedIo::EXCEED_OPS;
}
return nActions == nExpectedActions;
}