Use more C++17 features
Mainly structured bindings, inline variables, and class template
argument deduction, plus many more smaller things.
Change-Id: I810d17e0adb470426e4e30c898e03b3140ad052f
diff --git a/tests/daemon/face/datagram-transport.t.cpp b/tests/daemon/face/datagram-transport.t.cpp
index 6d41a1f..631e394 100644
--- a/tests/daemon/face/datagram-transport.t.cpp
+++ b/tests/daemon/face/datagram-transport.t.cpp
@@ -56,7 +56,7 @@
std::vector<uint8_t> readBuf(block1.size());
this->remoteRead(readBuf);
- BOOST_CHECK_EQUAL_COLLECTIONS(readBuf.begin(), readBuf.end(), block1.begin(), block1.end());
+ BOOST_TEST(readBuf == block1, boost::test_tools::per_element());
BOOST_CHECK_EQUAL(this->transport->getState(), TransportState::UP);
}
diff --git a/tests/daemon/face/generic-link-service.t.cpp b/tests/daemon/face/generic-link-service.t.cpp
index 11aeeb8..e4f0425 100644
--- a/tests/daemon/face/generic-link-service.t.cpp
+++ b/tests/daemon/face/generic-link-service.t.cpp
@@ -229,8 +229,7 @@
auto interest1 = makeInterest("/23Rd9hEiR");
lp::Packet lpPacket;
- lpPacket.set<lp::FragmentField>(std::make_pair(
- interest1->wireEncode().begin(), interest1->wireEncode().end()));
+ lpPacket.set<lp::FragmentField>({interest1->wireEncode().begin(), interest1->wireEncode().end()});
lpPacket.set<lp::SequenceField>(0); // force LpPacket encoding
transport->receivePacket(lpPacket.wireEncode());
@@ -264,8 +263,7 @@
auto data1 = makeData("/12345689");
lp::Packet lpPacket;
- lpPacket.set<lp::FragmentField>(std::make_pair(
- data1->wireEncode().begin(), data1->wireEncode().end()));
+ lpPacket.set<lp::FragmentField>({data1->wireEncode().begin(), data1->wireEncode().end()});
lpPacket.set<lp::SequenceField>(0); // force LpPacket encoding
transport->receivePacket(lpPacket.wireEncode());
@@ -282,11 +280,11 @@
options.allowLocalFields = false;
initialize(options);
- lp::Nack nack1 = makeNack(*makeInterest("/localhost/test", false, std::nullopt, 323),
- lp::NackReason::NO_ROUTE);
+ auto nack1 = makeNack(*makeInterest("/localhost/test", false, std::nullopt, 323),
+ lp::NackReason::NO_ROUTE);
lp::Packet lpPacket;
- lpPacket.set<lp::FragmentField>(std::make_pair(
- nack1.getInterest().wireEncode().begin(), nack1.getInterest().wireEncode().end()));
+ lpPacket.set<lp::FragmentField>({nack1.getInterest().wireEncode().begin(),
+ nack1.getInterest().wireEncode().end()});
lpPacket.set<lp::NackField>(nack1.getHeader());
transport->receivePacket(lpPacket.wireEncode());
@@ -430,12 +428,9 @@
// fragment the packet
LpFragmenter fragmenter({});
- size_t mtu = 100;
- bool isOk = false;
- std::vector<lp::Packet> frags;
- std::tie(isOk, frags) = fragmenter.fragmentPacket(packet, mtu);
+ auto [isOk, frags] = fragmenter.fragmentPacket(packet, 100);
BOOST_REQUIRE(isOk);
- BOOST_CHECK_GT(frags.size(), 1);
+ BOOST_TEST(frags.size() > 1);
// receive the fragments
for (ssize_t fragIndex = frags.size() - 1; fragIndex >= 0; --fragIndex) {
@@ -970,11 +965,11 @@
options.allowLocalFields = true;
initialize(options);
- lp::Nack nack = makeNack(*makeInterest("/localhost/test", false, std::nullopt, 123),
- lp::NackReason::NO_ROUTE);
+ auto nack = makeNack(*makeInterest("/localhost/test", false, std::nullopt, 123),
+ lp::NackReason::NO_ROUTE);
lp::Packet packet;
- packet.set<lp::FragmentField>(std::make_pair(
- nack.getInterest().wireEncode().begin(), nack.getInterest().wireEncode().end()));
+ packet.set<lp::FragmentField>({nack.getInterest().wireEncode().begin(),
+ nack.getInterest().wireEncode().end()});
packet.set<lp::NackField>(nack.getHeader());
packet.set<lp::NextHopFaceIdField>(1000);
@@ -1205,11 +1200,11 @@
BOOST_AUTO_TEST_CASE(ReceiveCongestionMarkNack)
{
- lp::Nack nack = makeNack(*makeInterest("/localhost/test", false, std::nullopt, 123),
- lp::NackReason::NO_ROUTE);
+ auto nack = makeNack(*makeInterest("/localhost/test", false, std::nullopt, 123),
+ lp::NackReason::NO_ROUTE);
lp::Packet packet;
- packet.set<lp::FragmentField>(std::make_pair(
- nack.getInterest().wireEncode().begin(), nack.getInterest().wireEncode().end()));
+ packet.set<lp::FragmentField>({nack.getInterest().wireEncode().begin(),
+ nack.getInterest().wireEncode().end()});
packet.set<lp::NackField>(nack.getHeader());
packet.set<lp::CongestionMarkField>(1);
@@ -1310,11 +1305,11 @@
options.allowSelfLearning = true;
initialize(options);
- lp::Nack nack = makeNack(*makeInterest("/localhost/test", false, std::nullopt, 123),
- lp::NackReason::NO_ROUTE);
+ auto nack = makeNack(*makeInterest("/localhost/test", false, std::nullopt, 123),
+ lp::NackReason::NO_ROUTE);
lp::Packet packet;
- packet.set<lp::FragmentField>(std::make_pair(
- nack.getInterest().wireEncode().begin(), nack.getInterest().wireEncode().end()));
+ packet.set<lp::FragmentField>({nack.getInterest().wireEncode().begin(),
+ nack.getInterest().wireEncode().end()});
packet.set<lp::NackField>(nack.getHeader());
packet.set<lp::NonDiscoveryField>(lp::EmptyValue{});
@@ -1418,11 +1413,11 @@
options.allowSelfLearning = true;
initialize(options);
- lp::Nack nack = makeNack(*makeInterest("/localhost/test", false, std::nullopt, 123),
- lp::NackReason::NO_ROUTE);
+ auto nack = makeNack(*makeInterest("/localhost/test", false, std::nullopt, 123),
+ lp::NackReason::NO_ROUTE);
lp::Packet packet;
- packet.set<lp::FragmentField>(std::make_pair(
- nack.getInterest().wireEncode().begin(), nack.getInterest().wireEncode().end()));
+ packet.set<lp::FragmentField>({nack.getInterest().wireEncode().begin(),
+ nack.getInterest().wireEncode().end()});
packet.set<lp::NackField>(nack.getHeader());
auto pah = makePrefixAnnHeader("/local/ndn/prefix");
packet.set<lp::PrefixAnnouncementField>(pah);
diff --git a/tests/daemon/face/lp-fragmenter.t.cpp b/tests/daemon/face/lp-fragmenter.t.cpp
index 30eb8e9..8bd48c2 100644
--- a/tests/daemon/face/lp-fragmenter.t.cpp
+++ b/tests/daemon/face/lp-fragmenter.t.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2020, Regents of the University of California,
+ * Copyright (c) 2014-2022, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -52,9 +52,7 @@
auto data = makeData("/test/data123");
packet.add<lp::FragmentField>({data->wireEncode().begin(), data->wireEncode().end()});
- bool isOk = false;
- std::vector<lp::Packet> frags;
- std::tie(isOk, frags) = fragmenter.fragmentPacket(packet, mtu);
+ auto [isOk, frags] = fragmenter.fragmentPacket(packet, mtu);
BOOST_REQUIRE(isOk);
BOOST_REQUIRE_EQUAL(frags.size(), 1);
@@ -64,8 +62,7 @@
BOOST_CHECK(!frags[0].has<lp::FragCountField>());
BOOST_CHECK_LE(frags[0].wireEncode().size(), mtu);
- ndn::Buffer::const_iterator fragBegin, fragEnd;
- std::tie(fragBegin, fragEnd) = frags[0].get<lp::FragmentField>();
+ auto [fragBegin, fragEnd] = frags[0].get<lp::FragmentField>();
BOOST_CHECK_EQUAL_COLLECTIONS(data->wireEncode().begin(), data->wireEncode().end(),
fragBegin, fragEnd);
}
@@ -80,9 +77,7 @@
auto data = makeData("/test/data123/123456789/987654321/123456789");
packet.add<lp::FragmentField>({data->wireEncode().begin(), data->wireEncode().end()});
- bool isOk = false;
- std::vector<lp::Packet> frags;
- std::tie(isOk, frags) = fragmenter.fragmentPacket(packet, mtu);
+ auto [isOk, frags] = fragmenter.fragmentPacket(packet, mtu);
BOOST_REQUIRE(isOk);
BOOST_REQUIRE_EQUAL(frags.size(), 5);
@@ -93,8 +88,7 @@
BOOST_CHECK_EQUAL(frags[0].get<lp::FragIndexField>(), 0);
BOOST_CHECK_EQUAL(frags[0].get<lp::FragCountField>(), 5);
BOOST_CHECK_LE(frags[0].wireEncode().size(), mtu);
- ndn::Buffer::const_iterator frag0Begin, frag0End;
- std::tie(frag0Begin, frag0End) = frags[0].get<lp::FragmentField>();
+ auto [frag0Begin, frag0End] = frags[0].get<lp::FragmentField>();
BOOST_REQUIRE_LE(std::distance(frag0Begin, frag0End), reassembledPayload.size());
auto reassembledPos = std::copy(frag0Begin, frag0End, reassembledPayload.begin());
@@ -103,8 +97,7 @@
BOOST_CHECK_EQUAL(frags[1].get<lp::FragIndexField>(), 1);
BOOST_CHECK_EQUAL(frags[1].get<lp::FragCountField>(), 5);
BOOST_CHECK_LE(frags[1].wireEncode().size(), mtu);
- ndn::Buffer::const_iterator frag1Begin, frag1End;
- std::tie(frag1Begin, frag1End) = frags[1].get<lp::FragmentField>();
+ auto [frag1Begin, frag1End] = frags[1].get<lp::FragmentField>();
BOOST_REQUIRE_LE(std::distance(frag1Begin, frag1End),
std::distance(reassembledPos, reassembledPayload.end()));
reassembledPos = std::copy(frag1Begin, frag1End, reassembledPos);
@@ -114,8 +107,7 @@
BOOST_CHECK_EQUAL(frags[2].get<lp::FragIndexField>(), 2);
BOOST_CHECK_EQUAL(frags[2].get<lp::FragCountField>(), 5);
BOOST_CHECK_LE(frags[2].wireEncode().size(), mtu);
- ndn::Buffer::const_iterator frag2Begin, frag2End;
- std::tie(frag2Begin, frag2End) = frags[2].get<lp::FragmentField>();
+ auto [frag2Begin, frag2End] = frags[2].get<lp::FragmentField>();
BOOST_REQUIRE_LE(std::distance(frag2Begin, frag2End),
std::distance(reassembledPos, reassembledPayload.end()));
reassembledPos = std::copy(frag2Begin, frag2End, reassembledPos);
@@ -125,8 +117,7 @@
BOOST_CHECK_EQUAL(frags[3].get<lp::FragIndexField>(), 3);
BOOST_CHECK_EQUAL(frags[3].get<lp::FragCountField>(), 5);
BOOST_CHECK_LE(frags[3].wireEncode().size(), mtu);
- ndn::Buffer::const_iterator frag3Begin, frag3End;
- std::tie(frag3Begin, frag3End) = frags[3].get<lp::FragmentField>();
+ auto [frag3Begin, frag3End] = frags[3].get<lp::FragmentField>();
BOOST_REQUIRE_LE(std::distance(frag3Begin, frag3End),
std::distance(reassembledPos, reassembledPayload.end()));
reassembledPos = std::copy(frag3Begin, frag3End, reassembledPos);
@@ -136,14 +127,12 @@
BOOST_CHECK_EQUAL(frags[4].get<lp::FragIndexField>(), 4);
BOOST_CHECK_EQUAL(frags[4].get<lp::FragCountField>(), 5);
BOOST_CHECK_LE(frags[4].wireEncode().size(), mtu);
- ndn::Buffer::const_iterator frag4Begin, frag4End;
- std::tie(frag4Begin, frag4End) = frags[4].get<lp::FragmentField>();
+ auto [frag4Begin, frag4End] = frags[4].get<lp::FragmentField>();
BOOST_REQUIRE_LE(std::distance(frag4Begin, frag4End),
std::distance(reassembledPos, reassembledPayload.end()));
std::copy(frag4Begin, frag4End, reassembledPos);
- BOOST_CHECK_EQUAL_COLLECTIONS(data->wireEncode().begin(), data->wireEncode().end(),
- reassembledPayload.begin(), reassembledPayload.end());
+ BOOST_TEST(data->wireEncode() == reassembledPayload, boost::test_tools::per_element());
}
BOOST_AUTO_TEST_CASE(MtuTooSmall)
diff --git a/tests/daemon/face/lp-reliability.t.cpp b/tests/daemon/face/lp-reliability.t.cpp
index 526708f..0d891e0 100644
--- a/tests/daemon/face/lp-reliability.t.cpp
+++ b/tests/daemon/face/lp-reliability.t.cpp
@@ -140,8 +140,7 @@
getPktNum(const lp::Packet& pkt)
{
BOOST_REQUIRE(pkt.has<lp::FragmentField>());
- ndn::Buffer::const_iterator begin, end;
- std::tie(begin, end) = pkt.get<lp::FragmentField>();
+ auto [begin, end] = pkt.get<lp::FragmentField>();
if (std::distance(begin, end) < 4) {
return 0;
}
diff --git a/tests/daemon/face/tcp-transport.t.cpp b/tests/daemon/face/tcp-transport.t.cpp
index 1ad0b70..c01aaef 100644
--- a/tests/daemon/face/tcp-transport.t.cpp
+++ b/tests/daemon/face/tcp-transport.t.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2019, Regents of the University of California,
+ * Copyright (c) 2014-2022, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -187,14 +187,14 @@
// measure retry intervals
auto retryTime1 = time::steady_clock::now();
- auto expectedWait1 = TcpTransport::s_initialReconnectWait;
+ auto expectedWait1 = TcpTransport::INITIAL_RECONNECT_DELAY;
BOOST_REQUIRE_EQUAL(this->limitedIo.run(2, expectedWait1 + 1_s), // add some slack
LimitedIo::EXCEED_OPS);
auto retryTime2 = time::steady_clock::now();
BOOST_CHECK_EQUAL(transportObserver->getState(), TransportState::DOWN);
auto expectedWait2 = time::duration_cast<time::nanoseconds>(expectedWait1 *
- TcpTransport::s_reconnectWaitMultiplier);
+ TcpTransport::RECONNECT_DELAY_MULTIPLIER);
BOOST_REQUIRE_EQUAL(this->limitedIo.run(2, expectedWait2 + 1_s), // add some slack
LimitedIo::EXCEED_OPS);
auto retryTime3 = time::steady_clock::now();
@@ -210,7 +210,7 @@
this->startAccept(remoteEp);
auto expectedWait3 = time::duration_cast<time::nanoseconds>(expectedWait2 *
- TcpTransport::s_reconnectWaitMultiplier);
+ TcpTransport::RECONNECT_DELAY_MULTIPLIER);
BOOST_REQUIRE_EQUAL(this->limitedIo.run(3, // reconnect, handleReconnect, async_accept
expectedWait3 + 1_s), LimitedIo::EXCEED_OPS);
BOOST_CHECK_EQUAL(transportObserver->getState(), TransportState::UP);
diff --git a/tests/daemon/face/unicast-udp-transport.t.cpp b/tests/daemon/face/unicast-udp-transport.t.cpp
index e5962db..24d47fd 100644
--- a/tests/daemon/face/unicast-udp-transport.t.cpp
+++ b/tests/daemon/face/unicast-udp-transport.t.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2019, Regents of the University of California,
+ * Copyright (c) 2014-2022, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -162,7 +162,7 @@
});
BOOST_REQUIRE_EQUAL(limitedIo.run(1, 1_s), LimitedIo::EXCEED_OPS);
- BOOST_CHECK_EQUAL_COLLECTIONS(readBuf.begin(), readBuf.end(), block1.begin(), block1.end());
+ BOOST_TEST(readBuf == block1, boost::test_tools::per_element());
Block block2 = ndn::encoding::makeStringBlock(301, "world");
ndn::Buffer buf(block2.begin(), block2.end());
diff --git a/tests/daemon/fw/asf-strategy.t.cpp b/tests/daemon/fw/asf-strategy.t.cpp
index f07e72a..e80a287 100644
--- a/tests/daemon/fw/asf-strategy.t.cpp
+++ b/tests/daemon/fw/asf-strategy.t.cpp
@@ -114,11 +114,9 @@
shared_ptr<TopologyAppLink> consumer;
shared_ptr<TopologyAppLink> producer;
- static const Name PRODUCER_PREFIX;
+ static inline const Name PRODUCER_PREFIX{"/hr/C"};
};
-const Name AsfGridFixture::PRODUCER_PREFIX("/hr/C");
-
class AsfStrategyParametersGridFixture : public AsfGridFixture
{
protected:
diff --git a/tests/daemon/fw/strategy-nack-return.t.cpp b/tests/daemon/fw/strategy-nack-return.t.cpp
index a091fb5..b928c92 100644
--- a/tests/daemon/fw/strategy-nack-return.t.cpp
+++ b/tests/daemon/fw/strategy-nack-return.t.cpp
@@ -274,26 +274,12 @@
BOOST_CHECK_GT(nNacksD, 0);
}
-template<lp::NackReason X, lp::NackReason Y, lp::NackReason R>
+template<auto X, auto Y, auto R>
struct NackReasonCombination
{
- static lp::NackReason
- getX()
- {
- return X;
- }
-
- static lp::NackReason
- getY()
- {
- return Y;
- }
-
- static lp::NackReason
- getExpectedResult()
- {
- return R;
- }
+ static constexpr lp::NackReason firstReason{X};
+ static constexpr lp::NackReason secondReason{Y};
+ static constexpr lp::NackReason expectedResult{R};
};
using NackReasonCombinations = boost::mpl::vector<
@@ -320,24 +306,24 @@
Combination, NackReasonCombinations,
StrategyNackReturnFixture<BestRouteStrategy>)
{
- fib::Entry& fibEntry = *fib.insert(Name()).first;
+ auto& fibEntry = *fib.insert(Name()).first;
fib.addOrUpdateNextHop(fibEntry, *face3, 10);
fib.addOrUpdateNextHop(fibEntry, *face4, 20);
fib.addOrUpdateNextHop(fibEntry, *face5, 30);
auto interest1 = makeInterest("/F6sEwB24I", false, std::nullopt, 282);
- shared_ptr<pit::Entry> pitEntry = pit.insert(*interest1).first;
+ auto pitEntry = pit.insert(*interest1).first;
pitEntry->insertOrUpdateInRecord(*face1, *interest1);
pitEntry->insertOrUpdateOutRecord(*face3, *interest1);
pitEntry->insertOrUpdateOutRecord(*face4, *interest1);
- lp::Nack nack3 = makeNack(*interest1, Combination::getX());
+ lp::Nack nack3 = makeNack(*interest1, Combination::firstReason);
pitEntry->getOutRecord(*face3)->setIncomingNack(nack3);
strategy.afterReceiveNack(nack3, FaceEndpoint(*face3, 0), pitEntry);
BOOST_CHECK_EQUAL(strategy.sendNackHistory.size(), 0);
- lp::Nack nack4 = makeNack(*interest1, Combination::getY());
+ lp::Nack nack4 = makeNack(*interest1, Combination::secondReason);
pitEntry->getOutRecord(*face4)->setIncomingNack(nack4);
strategy.afterReceiveNack(nack4, FaceEndpoint(*face4, 0), pitEntry);
@@ -345,7 +331,7 @@
BOOST_CHECK_EQUAL(strategy.sendNackHistory[0].pitInterest.wireEncode(),
pitEntry->getInterest().wireEncode());
BOOST_CHECK_EQUAL(strategy.sendNackHistory[0].outFaceId, face1->getId());
- BOOST_CHECK_EQUAL(strategy.sendNackHistory[0].header.getReason(), Combination::getExpectedResult());
+ BOOST_CHECK_EQUAL(strategy.sendNackHistory[0].header.getReason(), Combination::expectedResult);
}
BOOST_AUTO_TEST_SUITE_END() // TestStrategyNackReturn
diff --git a/tests/daemon/fw/strategy-tester.hpp b/tests/daemon/fw/strategy-tester.hpp
index 03c2f77..5391dde 100644
--- a/tests/daemon/fw/strategy-tester.hpp
+++ b/tests/daemon/fw/strategy-tester.hpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2021, Regents of the University of California,
+ * Copyright (c) 2014-2022, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -91,7 +91,7 @@
++nActions;
});
- std::forward<F>(f)();
+ std::invoke(std::forward<F>(f));
if (nActions < nExpectedActions) {
// If strategy doesn't forward anything (e.g., decides not to forward an Interest), the number
diff --git a/tests/daemon/fw/topology-tester.cpp b/tests/daemon/fw/topology-tester.cpp
index 73f9999..c44d61d 100644
--- a/tests/daemon/fw/topology-tester.cpp
+++ b/tests/daemon/fw/topology-tester.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2020, Regents of the University of California,
+ * Copyright (c) 2014-2022, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -74,10 +74,7 @@
TopologyLink::addFace(TopologyNode i, shared_ptr<Face> face)
{
auto receiveCb = [this, i] (const Block& packet) { transmit(i, packet); };
-
- auto ret = m_transports.emplace(std::piecewise_construct,
- std::forward_as_tuple(i),
- std::forward_as_tuple(std::move(face), std::move(receiveCb)));
+ auto ret = m_transports.try_emplace(i, std::move(face), std::move(receiveCb));
BOOST_ASSERT(ret.second);
auto& node = ret.first->second;
@@ -93,12 +90,12 @@
const auto& blockedDestinations = m_transports.at(i).blockedDestinations;
- for (const auto& p : m_transports) {
- if (p.first == i || blockedDestinations.count(p.first) > 0) {
+ for (const auto& [node, transport] : m_transports) {
+ if (node == i || blockedDestinations.count(node) > 0) {
continue;
}
- getScheduler().schedule(m_delay, [packet, recipient = p.second.transport] {
+ getScheduler().schedule(m_delay, [packet, recipient = transport.transport] {
recipient->receivePacket(packet);
});
}
diff --git a/tests/daemon/fw/unsolicited-data-policy.t.cpp b/tests/daemon/fw/unsolicited-data-policy.t.cpp
index 5c8c8ad..77722c7 100644
--- a/tests/daemon/fw/unsolicited-data-policy.t.cpp
+++ b/tests/daemon/fw/unsolicited-data-policy.t.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2021, Regents of the University of California,
+ * Copyright (c) 2014-2022, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -95,8 +95,8 @@
struct FaceScopePolicyTest
{
using PolicyType = Policy;
- using ShouldAdmitLocal = std::integral_constant<bool, shouldAdmitLocal>;
- using ShouldAdmitNonLocal = std::integral_constant<bool, shouldAdmitNonLocal>;
+ using ShouldAdmitLocal = std::bool_constant<shouldAdmitLocal>;
+ using ShouldAdmitNonLocal = std::bool_constant<shouldAdmitNonLocal>;
};
using FaceScopePolicyTests = boost::mpl::vector<
diff --git a/tests/daemon/limited-io.cpp b/tests/daemon/limited-io.cpp
index aeb1ea7..c7e9b1b 100644
--- a/tests/daemon/limited-io.cpp
+++ b/tests/daemon/limited-io.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2019, Regents of the University of California,
+ * Copyright (c) 2014-2022, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -32,9 +32,6 @@
namespace nfd {
namespace tests {
-const int LimitedIo::UNLIMITED_OPS = std::numeric_limits<int>::max();
-const time::nanoseconds LimitedIo::UNLIMITED_TIME = time::nanoseconds::min();
-
LimitedIo::LimitedIo(GlobalIoTimeFixture* fixture)
: m_fixture(fixture)
{
diff --git a/tests/daemon/limited-io.hpp b/tests/daemon/limited-io.hpp
index a34d20e..efa35c9 100644
--- a/tests/daemon/limited-io.hpp
+++ b/tests/daemon/limited-io.hpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2019, Regents of the University of California,
+ * Copyright (c) 2014-2022, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -95,8 +95,8 @@
afterTimeout();
public:
- static const int UNLIMITED_OPS;
- static const time::nanoseconds UNLIMITED_TIME;
+ static constexpr int UNLIMITED_OPS = std::numeric_limits<int>::max();
+ static constexpr time::nanoseconds UNLIMITED_TIME = time::nanoseconds::min();
private:
GlobalIoTimeFixture* m_fixture;
diff --git a/tests/daemon/mgmt/fib-manager.t.cpp b/tests/daemon/mgmt/fib-manager.t.cpp
index 6131670..544eda5 100644
--- a/tests/daemon/mgmt/fib-manager.t.cpp
+++ b/tests/daemon/mgmt/fib-manager.t.cpp
@@ -438,8 +438,7 @@
}
BOOST_CHECK_EQUAL(actualPrefixes.size(), 0);
- BOOST_CHECK_EQUAL_COLLECTIONS(receivedRecords.begin(), receivedRecords.end(),
- expectedRecords.begin(), expectedRecords.end());
+ BOOST_TEST(receivedRecords == expectedRecords, boost::test_tools::per_element());
}
BOOST_AUTO_TEST_SUITE_END() // List
diff --git a/tests/daemon/mgmt/manager-common-fixture.cpp b/tests/daemon/mgmt/manager-common-fixture.cpp
index 83136be..3188ee4 100644
--- a/tests/daemon/mgmt/manager-common-fixture.cpp
+++ b/tests/daemon/mgmt/manager-common-fixture.cpp
@@ -28,8 +28,6 @@
namespace nfd {
namespace tests {
-const Name CommandInterestSignerFixture::DEFAULT_COMMAND_SIGNER_IDENTITY("/CommandInterestSignerFixture-identity");
-
CommandInterestSignerFixture::CommandInterestSignerFixture()
: m_signer(m_keyChain)
{
diff --git a/tests/daemon/mgmt/manager-common-fixture.hpp b/tests/daemon/mgmt/manager-common-fixture.hpp
index e717172..005d456 100644
--- a/tests/daemon/mgmt/manager-common-fixture.hpp
+++ b/tests/daemon/mgmt/manager-common-fixture.hpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2021, Regents of the University of California,
+ * Copyright (c) 2014-2022, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -65,7 +65,7 @@
const Name& identity = DEFAULT_COMMAND_SIGNER_IDENTITY);
protected:
- static const Name DEFAULT_COMMAND_SIGNER_IDENTITY;
+ static inline const Name DEFAULT_COMMAND_SIGNER_IDENTITY{"/CommandInterestSignerFixture-identity"};
private:
ndn::security::InterestSigner m_signer;
@@ -188,7 +188,7 @@
}
};
-template<int CODE>
+template<auto CODE>
class CommandFailure
{
public:
diff --git a/tests/daemon/mgmt/rib-manager-sl-announce.t.cpp b/tests/daemon/mgmt/rib-manager-sl-announce.t.cpp
index 4d15659..ebfe7d0 100644
--- a/tests/daemon/mgmt/rib-manager-sl-announce.t.cpp
+++ b/tests/daemon/mgmt/rib-manager-sl-announce.t.cpp
@@ -274,7 +274,7 @@
BOOST_AUTO_TEST_CASE(AnnounceExpired)
{
- auto pa = makeTrustedAnn("/awrVv6V7", 1_h, std::make_pair(-3_h, -1_h));
+ auto pa = makeTrustedAnn("/awrVv6V7", 1_h, std::pair(-3_h, -1_h));
BOOST_CHECK_EQUAL(slAnnounceSync(pa, 9087, 1_h), SlAnnounceResult::EXPIRED);
BOOST_CHECK(findAnnRoute("/awrVv6V7", 9087) == nullptr);
diff --git a/tests/daemon/mgmt/rib-manager.t.cpp b/tests/daemon/mgmt/rib-manager.t.cpp
index 682eb30..be4638f 100644
--- a/tests/daemon/mgmt/rib-manager.t.cpp
+++ b/tests/daemon/mgmt/rib-manager.t.cpp
@@ -494,8 +494,7 @@
}
BOOST_CHECK_EQUAL(actualPrefixes.size(), 0);
- BOOST_CHECK_EQUAL_COLLECTIONS(receivedRecords.begin(), receivedRecords.end(),
- expectedRecords.begin(), expectedRecords.end());
+ BOOST_TEST(receivedRecords == expectedRecords, boost::test_tools::per_element());
}
BOOST_FIXTURE_TEST_SUITE(FaceMonitor, LocalhostAuthorizedRibManagerFixture)
diff --git a/tests/daemon/mgmt/strategy-choice-manager.t.cpp b/tests/daemon/mgmt/strategy-choice-manager.t.cpp
index 7fdd8fa..3e42d1c 100644
--- a/tests/daemon/mgmt/strategy-choice-manager.t.cpp
+++ b/tests/daemon/mgmt/strategy-choice-manager.t.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2021, Regents of the University of California,
+ * Copyright (c) 2014-2022, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -62,12 +62,8 @@
Name
getInstanceName(const Name& name) const
{
- bool hasEntry = false;
- Name instanceName;
- std::tie(hasEntry, instanceName) = sc.get(name);
- return hasEntry ?
- instanceName :
- Name("/no-StrategyChoice-entry-at").append(name);
+ auto [hasEntry, instanceName] = sc.get(name);
+ return hasEntry ? instanceName : Name("/no-StrategyChoice-entry-at").append(name);
}
protected:
diff --git a/tests/daemon/rib/readvertise/readvertise.t.cpp b/tests/daemon/rib/readvertise/readvertise.t.cpp
index 8916c00..ffcab71 100644
--- a/tests/daemon/rib/readvertise/readvertise.t.cpp
+++ b/tests/daemon/rib/readvertise/readvertise.t.cpp
@@ -220,11 +220,10 @@
this->setDestinationAvailability(true);
std::set<Name> advertisedPrefixes;
boost::copy(destination->advertiseHistory | boost::adaptors::transformed(
- [] (const DummyReadvertiseDestination::HistoryEntry& he) { return he.prefix; }),
+ [] (const auto& he) { return he.prefix; }),
std::inserter(advertisedPrefixes, advertisedPrefixes.end()));
- std::set<Name> expectedPrefixes{"/A", "/B"};
- BOOST_CHECK_EQUAL_COLLECTIONS(advertisedPrefixes.begin(), advertisedPrefixes.end(),
- expectedPrefixes.begin(), expectedPrefixes.end());
+ const std::set<Name> expectedPrefixes{"/A", "/B"};
+ BOOST_TEST(advertisedPrefixes == expectedPrefixes, boost::test_tools::per_element());
destination->advertiseHistory.clear();
this->setDestinationAvailability(false);
diff --git a/tests/daemon/rib/rib-update.t.cpp b/tests/daemon/rib/rib-update.t.cpp
index 81ee10e..90c80f0 100644
--- a/tests/daemon/rib/rib-update.t.cpp
+++ b/tests/daemon/rib/rib-update.t.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2019, Regents of the University of California,
+ * Copyright (c) 2014-2022, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -27,25 +27,20 @@
#include "rib/rib-update-batch.hpp"
#include "tests/test-common.hpp"
-#include "tests/daemon/global-io-fixture.hpp"
#include "tests/daemon/rib/create-route.hpp"
namespace nfd {
namespace rib {
namespace tests {
-using namespace nfd::tests;
-
-BOOST_FIXTURE_TEST_SUITE(TestRibUpdate, GlobalIoFixture)
+BOOST_AUTO_TEST_SUITE(TestRibUpdate)
BOOST_AUTO_TEST_CASE(BatchBasic)
{
const uint64_t faceId = 1;
-
RibUpdateBatch batch(faceId);
Route routeRegister = createRoute(faceId, 128, 10, ndn::nfd::ROUTE_FLAG_CHILD_INHERIT);
-
RibUpdate registerUpdate;
registerUpdate.setAction(RibUpdate::REGISTER)
.setName("/a")
@@ -56,7 +51,6 @@
BOOST_CHECK_EQUAL(batch.getFaceId(), faceId);
Route routeUnregister = createRoute(faceId, 0, 0, ndn::nfd::ROUTE_FLAG_CAPTURE);
-
RibUpdate unregisterUpdate;
unregisterUpdate.setAction(RibUpdate::UNREGISTER)
.setName("/a/b")
@@ -65,7 +59,7 @@
batch.add(unregisterUpdate);
BOOST_REQUIRE_EQUAL(batch.size(), 2);
- RibUpdateBatch::const_iterator it = batch.begin();
+ auto it = batch.begin();
BOOST_CHECK_EQUAL(it->getAction(), RibUpdate::REGISTER);
BOOST_CHECK_EQUAL(it->getName(), "/a");
diff --git a/tests/daemon/table/cs.t.cpp b/tests/daemon/table/cs.t.cpp
index 85886da..b8e34de 100644
--- a/tests/daemon/table/cs.t.cpp
+++ b/tests/daemon/table/cs.t.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2019, Regents of the University of California,
+ * Copyright (c) 2014-2022, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -264,12 +264,12 @@
insert(12, nameAB);
insert(4, nameD);
- std::set<Name> expected = {nameA, nameAB, nameABC, nameD};
+ const std::set<Name> expected{nameA, nameAB, nameABC, nameD};
std::set<Name> actual;
for (const auto& csEntry : cs) {
actual.insert(csEntry.getName());
}
- BOOST_CHECK_EQUAL_COLLECTIONS(actual.begin(), actual.end(), expected.begin(), expected.end());
+ BOOST_TEST(actual == expected, boost::test_tools::per_element());
}
BOOST_AUTO_TEST_SUITE_END() // TestCs
diff --git a/tests/daemon/table/dead-nonce-list.t.cpp b/tests/daemon/table/dead-nonce-list.t.cpp
index b4bcec9..44b0bfd 100644
--- a/tests/daemon/table/dead-nonce-list.t.cpp
+++ b/tests/daemon/table/dead-nonce-list.t.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2021, Regents of the University of California,
+ * Copyright (c) 2014-2022, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -145,9 +145,6 @@
scheduler::ScopedEventId addNonceEvent;
};
-const time::nanoseconds PeriodicalInsertionFixture::LIFETIME;
-const time::nanoseconds PeriodicalInsertionFixture::ADD_INTERVAL;
-
BOOST_FIXTURE_TEST_CASE(Lifetime, PeriodicalInsertionFixture)
{
BOOST_CHECK_EQUAL(dnl.getLifetime(), LIFETIME);
diff --git a/tests/daemon/table/fib.t.cpp b/tests/daemon/table/fib.t.cpp
index 101b3b9..1655fac 100644
--- a/tests/daemon/table/fib.t.cpp
+++ b/tests/daemon/table/fib.t.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2019, Regents of the University of California,
+ * Copyright (c) 2014-2022, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -92,7 +92,7 @@
// [(face1,30), (face2,40)]
BOOST_CHECK_EQUAL(entry.getNextHops().size(), 2);
{
- NextHopList::const_iterator it = entry.getNextHops().begin();
+ auto it = entry.getNextHops().begin();
BOOST_REQUIRE(it != entry.getNextHops().end());
BOOST_CHECK_EQUAL(&it->getFace(), face1.get());
BOOST_CHECK_EQUAL(it->getCost(), 30);
@@ -112,7 +112,7 @@
// [(face2,10), (face1,30)]
BOOST_CHECK_EQUAL(entry.getNextHops().size(), 2);
{
- NextHopList::const_iterator it = entry.getNextHops().begin();
+ auto it = entry.getNextHops().begin();
BOOST_REQUIRE(it != entry.getNextHops().end());
BOOST_CHECK_EQUAL(&it->getFace(), face2.get());
BOOST_CHECK_EQUAL(it->getCost(), 10);
diff --git a/tests/daemon/table/name-tree.t.cpp b/tests/daemon/table/name-tree.t.cpp
index 2649834..6c410aa 100644
--- a/tests/daemon/table/name-tree.t.cpp
+++ b/tests/daemon/table/name-tree.t.cpp
@@ -56,6 +56,7 @@
}
BOOST_AUTO_TEST_SUITE(Hashtable)
+
using name_tree::Hashtable;
BOOST_AUTO_TEST_CASE(Modifiers)
@@ -256,7 +257,7 @@
npe.insertPitEntry(pit2);
BOOST_CHECK_EQUAL(npe.getPitEntries().size(), 2);
- pit::Entry* pit1ptr = pit1.get();
+ auto* pit1ptr = pit1.get();
weak_ptr<pit::Entry> pit1weak(pit1);
pit1.reset();
BOOST_CHECK_EQUAL(pit1weak.use_count(), 1); // npe is the sole owner of pit1
@@ -338,7 +339,6 @@
Entry* npe0 = nt.findExactMatch(name0);
BOOST_CHECK(npe0 == nullptr);
-
// findLongestPrefixMatch
Entry* temp = nullptr;
@@ -493,12 +493,10 @@
}
protected:
- static const size_t N_BUCKETS = 16;
+ static constexpr size_t N_BUCKETS = 16;
NameTree nt;
};
-const size_t EnumerationFixture::N_BUCKETS;
-
BOOST_FIXTURE_TEST_CASE(IteratorFullEnumerate, EnumerationFixture)
{
nt.lookup("/a/b/c");
@@ -556,7 +554,7 @@
// Accept "root" nameA only
auto&& enumerable = nt.partialEnumerate("/a", [] (const Entry& entry) {
- return std::make_pair(entry.getName() == "/a", true);
+ return std::pair(entry.getName() == "/a", true);
});
EnumerationVerifier(enumerable)
@@ -570,7 +568,7 @@
// Accept anything except "root" nameA
auto&& enumerable = nt.partialEnumerate("/a", [] (const Entry& entry) {
- return std::make_pair(entry.getName() != "/a", true);
+ return std::pair(entry.getName() != "/a", true);
});
EnumerationVerifier(enumerable)
@@ -586,7 +584,7 @@
// No NameA
// No SubTree from NameAB
auto&& enumerable = nt.partialEnumerate("/a", [] (const Entry& entry) {
- return std::make_pair(entry.getName() != "/a", entry.getName() != "/a/b");
+ return std::pair(entry.getName() != "/a", entry.getName() != "/a/b");
});
EnumerationVerifier(enumerable)
@@ -604,7 +602,7 @@
// No NameA
// No SubTree from NameAC
auto&& enumerable = nt.partialEnumerate("/a", [] (const Entry& entry) {
- return std::make_pair(entry.getName() != "/a", entry.getName() != "/a/c");
+ return std::pair(entry.getName() != "/a", entry.getName() != "/a/c");
});
EnumerationVerifier(enumerable)
@@ -621,7 +619,7 @@
// No Subtree from NameA
auto&& enumerable = nt.partialEnumerate("/a", [] (const Entry& entry) {
- return std::make_pair(true, entry.getName() != "/a");
+ return std::pair(true, entry.getName() != "/a");
});
EnumerationVerifier(enumerable)
@@ -647,23 +645,20 @@
nt.lookup("/E");
nt.lookup("/F");
- auto&& enumerable = nt.partialEnumerate("/A",
- [] (const Entry& entry) {
- bool visitEntry = false;
- bool visitChildren = false;
+ auto&& enumerable = nt.partialEnumerate("/A", [] (const Entry& entry) {
+ bool visitEntry = false;
+ bool visitChildren = false;
- Name name = entry.getName();
+ const Name& name = entry.getName();
+ if (name == "/" || name == "/A/B" || name == "/A/B/C" || name == "/A/D") {
+ visitEntry = true;
+ }
+ if (name == "/" || name == "/A" || name == "/F") {
+ visitChildren = true;
+ }
- if (name == "/" || name == "/A/B" || name == "/A/B/C" || name == "/A/D") {
- visitEntry = true;
- }
-
- if (name == "/" || name == "/A" || name == "/F") {
- visitChildren = true;
- }
-
- return std::make_pair(visitEntry, visitChildren);
- });
+ return std::pair(visitEntry, visitChildren);
+ });
EnumerationVerifier(enumerable)
.expect("/A/B")
diff --git a/tests/daemon/table/pit.t.cpp b/tests/daemon/table/pit.t.cpp
index 03438d4..defa768 100644
--- a/tests/daemon/table/pit.t.cpp
+++ b/tests/daemon/table/pit.t.cpp
@@ -336,9 +336,9 @@
for (const auto& pitEntry : pit) {
actual.insert(&pitEntry.getInterest());
}
- std::set<const Interest*> expected = {interestA.get(), interestABC1.get(),
- interestABC2.get(), interestD.get()};
- BOOST_CHECK_EQUAL_COLLECTIONS(actual.begin(), actual.end(), expected.begin(), expected.end());
+ const auto expected = std::set{interestA.get(), interestABC1.get(),
+ interestABC2.get(), interestD.get()};
+ BOOST_TEST(actual == expected, boost::test_tools::per_element());
}
BOOST_AUTO_TEST_SUITE_END() // TestPit
diff --git a/tests/daemon/table/strategy-choice.t.cpp b/tests/daemon/table/strategy-choice.t.cpp
index d99ff44..ff6b754 100644
--- a/tests/daemon/table/strategy-choice.t.cpp
+++ b/tests/daemon/table/strategy-choice.t.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2021, Regents of the University of California,
+ * Copyright (c) 2014-2022, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -48,9 +48,7 @@
insertAndGet(const Name& prefix, const Name& instanceName)
{
BOOST_REQUIRE(sc.insert(prefix, instanceName));
- bool isFound;
- Name foundName;
- std::tie(isFound, foundName) = sc.get(prefix);
+ auto [isFound, foundName] = sc.get(prefix);
BOOST_REQUIRE(isFound);
return foundName;
}
diff --git a/tests/daemon/table/strategy-info-host.t.cpp b/tests/daemon/table/strategy-info-host.t.cpp
index 2a3a33e..e4323e4 100644
--- a/tests/daemon/table/strategy-info-host.t.cpp
+++ b/tests/daemon/table/strategy-info-host.t.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2019, Regents of the University of California,
+ * Copyright (c) 2014-2022, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -50,8 +50,7 @@
++g_DummyStrategyInfo_count;
}
- virtual
- ~DummyStrategyInfo()
+ ~DummyStrategyInfo() override
{
--g_DummyStrategyInfo_count;
}
@@ -85,19 +84,16 @@
{
StrategyInfoHost host;
g_DummyStrategyInfo_count = 0;
- bool isNew = false;
- DummyStrategyInfo* info = nullptr;
- std::tie(info, isNew) = host.insertStrategyInfo<DummyStrategyInfo>(3503);
+ auto [info, isNew] = host.insertStrategyInfo<DummyStrategyInfo>(3503);
BOOST_CHECK_EQUAL(isNew, true);
BOOST_CHECK_EQUAL(g_DummyStrategyInfo_count, 1);
BOOST_REQUIRE(info != nullptr);
BOOST_CHECK_EQUAL(info->m_id, 3503);
BOOST_CHECK_EQUAL(host.getStrategyInfo<DummyStrategyInfo>(), info);
- DummyStrategyInfo* info2 = nullptr;
- std::tie(info2, isNew) = host.insertStrategyInfo<DummyStrategyInfo>(1032);
- BOOST_CHECK_EQUAL(isNew, false);
+ auto [info2, isNew2] = host.insertStrategyInfo<DummyStrategyInfo>(1032);
+ BOOST_CHECK_EQUAL(isNew2, false);
BOOST_CHECK_EQUAL(g_DummyStrategyInfo_count, 1);
BOOST_CHECK_EQUAL(info2, info);
BOOST_CHECK_EQUAL(info->m_id, 3503);