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/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)