Slim down `common.hpp`
Change-Id: Ic9843a1b9ffc5b5b1fa6062c8250ba28c6aaa898
diff --git a/tests/chunks/consumer.t.cpp b/tests/chunks/consumer.t.cpp
index b1231dc..741ee03 100644
--- a/tests/chunks/consumer.t.cpp
+++ b/tests/chunks/consumer.t.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2016-2023, Regents of the University of California,
+ * Copyright (c) 2016-2024, Regents of the University of California,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University.
*
@@ -99,7 +99,7 @@
Consumer cons(security::getAcceptAllValidator(), output);
auto interest = makeInterest(name, true);
- std::vector<shared_ptr<Data>> dataStore;
+ std::vector<std::shared_ptr<Data>> dataStore;
for (size_t i = 0; i < testStrings.size(); ++i) {
auto data = makeData(Name(name).appendVersion(1).appendSegment(i));
@@ -153,8 +153,8 @@
Consumer consumer(security::getAcceptAllValidator());
Name prefix = Name("/ndn/chunks/test").appendVersion(1);
- auto discover = make_unique<DiscoverVersion>(face, prefix, options);
- auto pipeline = make_unique<PipelineInterestsDummy>(face, options);
+ auto discover = std::make_unique<DiscoverVersion>(face, prefix, options);
+ auto pipeline = std::make_unique<PipelineInterestsDummy>(face, options);
auto pipelinePtr = pipeline.get();
BOOST_CHECK_EQUAL(pipelinePtr->isPipelineRunning, false);
diff --git a/tests/chunks/discover-version.t.cpp b/tests/chunks/discover-version.t.cpp
index 01e360e..6b429b8 100644
--- a/tests/chunks/discover-version.t.cpp
+++ b/tests/chunks/discover-version.t.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2016-2023, Regents of the University of California,
+ * Copyright (c) 2016-2024, Regents of the University of California,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University.
*
@@ -42,7 +42,7 @@
void
run(const Name& prefix)
{
- discover = make_unique<DiscoverVersion>(face, prefix, opt);
+ discover = std::make_unique<DiscoverVersion>(face, prefix, opt);
discover->onDiscoverySuccess.connect([this] (const Name& versionedName) {
isDiscoveryFinished = true;
discoveredName = versionedName;
@@ -62,7 +62,7 @@
const uint64_t version = 1449227841747;
DummyClientFace face{m_io};
Options opt;
- unique_ptr<DiscoverVersion> discover;
+ std::unique_ptr<DiscoverVersion> discover;
std::optional<Name> discoveredName;
std::optional<uint64_t> discoveredVersion;
bool isDiscoveryFinished = false;
diff --git a/tests/chunks/pipeline-interests-aimd.t.cpp b/tests/chunks/pipeline-interests-aimd.t.cpp
index 12eeaa5..4688ee4 100644
--- a/tests/chunks/pipeline-interests-aimd.t.cpp
+++ b/tests/chunks/pipeline-interests-aimd.t.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2016-2022, Regents of the University of California,
+ * Copyright (c) 2016-2024, Regents of the University of California,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University.
*
@@ -29,6 +29,8 @@
#include "pipeline-interests-fixture.hpp"
+#include <cmath>
+
namespace ndn::chunks::tests {
using namespace ndn::tests;
@@ -45,16 +47,16 @@
void
createPipeline()
{
- auto pline = make_unique<PipelineInterestsAimd>(face, rttEstimator, opt);
+ auto pline = std::make_unique<PipelineInterestsAimd>(face, rttEstimator, opt);
pipeline = pline.get();
setPipeline(std::move(pline));
}
private:
- static shared_ptr<RttEstimatorWithStats::Options>
+ static std::shared_ptr<RttEstimatorWithStats::Options>
makeRttEstimatorOptions()
{
- auto rttOptions = make_shared<RttEstimatorWithStats::Options>();
+ auto rttOptions = std::make_shared<RttEstimatorWithStats::Options>();
rttOptions->alpha = 0.125;
rttOptions->beta = 0.25;
rttOptions->k = 4;
@@ -118,7 +120,7 @@
for (uint64_t i = pipeline->m_ssthresh; i < nDataSegments - 1; ++i) { // congestion avoidance
face.receive(*makeDataWithSegment(i));
advanceClocks(time::nanoseconds(1));
- BOOST_CHECK_CLOSE(pipeline->m_cwnd - preCwnd, opt.aiStep / floor(preCwnd), MARGIN);
+ BOOST_CHECK_CLOSE(pipeline->m_cwnd - preCwnd, opt.aiStep / std::floor(preCwnd), MARGIN);
preCwnd = pipeline->m_cwnd;
}
diff --git a/tests/chunks/pipeline-interests-cubic.t.cpp b/tests/chunks/pipeline-interests-cubic.t.cpp
index d84cce5..6a36105 100644
--- a/tests/chunks/pipeline-interests-cubic.t.cpp
+++ b/tests/chunks/pipeline-interests-cubic.t.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2016-2022, Regents of the University of California,
+ * Copyright (c) 2016-2024, Regents of the University of California,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University.
*
@@ -45,16 +45,16 @@
void
createPipeline()
{
- auto pline = make_unique<PipelineInterestsCubic>(face, rttEstimator, opt);
+ auto pline = std::make_unique<PipelineInterestsCubic>(face, rttEstimator, opt);
pipeline = pline.get();
setPipeline(std::move(pline));
}
private:
- static shared_ptr<RttEstimatorWithStats::Options>
+ static std::shared_ptr<RttEstimatorWithStats::Options>
makeRttEstimatorOptions()
{
- auto rttOptions = make_shared<RttEstimatorWithStats::Options>();
+ auto rttOptions = std::make_shared<RttEstimatorWithStats::Options>();
rttOptions->alpha = 0.125;
rttOptions->beta = 0.25;
rttOptions->k = 8;
diff --git a/tests/chunks/pipeline-interests-fixed.t.cpp b/tests/chunks/pipeline-interests-fixed.t.cpp
index b4f9723..24f14e9 100644
--- a/tests/chunks/pipeline-interests-fixed.t.cpp
+++ b/tests/chunks/pipeline-interests-fixed.t.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2016-2022, Regents of the University of California,
+ * Copyright (c) 2016-2024, Regents of the University of California,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University.
*
@@ -29,6 +29,8 @@
#include "pipeline-interests-fixture.hpp"
+#include <cmath>
+
namespace ndn::chunks::tests {
class PipelineInterestFixedFixture : public PipelineInterestsFixture
@@ -46,7 +48,7 @@
void
createPipeline()
{
- auto pline = make_unique<PipelineInterestsFixed>(face, opt);
+ auto pline = std::make_unique<PipelineInterestsFixed>(face, opt);
pipeline = pline.get();
setPipeline(std::move(pline));
}
@@ -187,7 +189,7 @@
BOOST_REQUIRE_EQUAL(face.sentInterests.size(), opt.maxPipelineSize * 3 - 2);
// nack for the first pipeline element (segment #0)
- auto nack = make_shared<lp::Nack>(face.sentInterests[opt.maxPipelineSize]);
+ auto nack = std::make_shared<lp::Nack>(face.sentInterests[opt.maxPipelineSize]);
nack->setReason(lp::NackReason::DUPLICATE);
face.receive(*nack);
@@ -232,7 +234,7 @@
advanceClocks(opt.interestLifetime);
// nack for the first pipeline element (segment #0)
- auto nack = make_shared<lp::Nack>(face.sentInterests[opt.maxPipelineSize]);
+ auto nack = std::make_shared<lp::Nack>(face.sentInterests[opt.maxPipelineSize]);
nack->setReason(lp::NackReason::DUPLICATE);
face.receive(*nack);
BOOST_CHECK_EQUAL(hasFailed, false);
@@ -261,7 +263,7 @@
// send nack for all the pipeline elements first interest
for (size_t i = 0; i < opt.maxPipelineSize; i++) {
- auto nack = make_shared<lp::Nack>(face.sentInterests[i]);
+ auto nack = std::make_shared<lp::Nack>(face.sentInterests[i]);
nack->setReason(lp::NackReason::CONGESTION);
face.receive(*nack);
advanceClocks(time::nanoseconds(1));
@@ -283,7 +285,7 @@
}
for (size_t j = 0; j < opt.maxPipelineSize; j++) {
- auto nack = make_shared<lp::Nack>(face.sentInterests[(opt.maxPipelineSize * i) + j]);
+ auto nack = std::make_shared<lp::Nack>(face.sentInterests[(opt.maxPipelineSize * i) + j]);
nack->setReason(lp::NackReason::CONGESTION);
face.receive(*nack);
advanceClocks(time::nanoseconds(1));
diff --git a/tests/chunks/pipeline-interests-fixture.hpp b/tests/chunks/pipeline-interests-fixture.hpp
index 215f544..4e42223 100644
--- a/tests/chunks/pipeline-interests-fixture.hpp
+++ b/tests/chunks/pipeline-interests-fixture.hpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2016-2023, Regents of the University of California,
+ * Copyright (c) 2016-2024, Regents of the University of California,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University.
*
@@ -44,21 +44,21 @@
{
protected:
void
- setPipeline(unique_ptr<PipelineInterests> pline)
+ setPipeline(std::unique_ptr<PipelineInterests> pline)
{
m_pipeline = std::move(pline);
}
- shared_ptr<Data>
+ std::shared_ptr<Data>
makeDataWithSegment(uint64_t segmentNo, bool setFinalBlockId = true) const
{
- auto data = make_shared<Data>(Name(name).appendVersion(0).appendSegment(segmentNo));
+ auto data = std::make_shared<Data>(Name(name).appendVersion(0).appendSegment(segmentNo));
if (setFinalBlockId)
data->setFinalBlock(name::Component::fromSegment(nDataSegments - 1));
return signData(data);
}
- shared_ptr<Data>
+ std::shared_ptr<Data>
makeDataWithSegmentAndCongMark(uint64_t segmentNo,
uint64_t congestionMark = 1,
bool setFinalBlockId = true) const
@@ -83,7 +83,7 @@
bool hasFailed = false;
private:
- unique_ptr<PipelineInterests> m_pipeline;
+ std::unique_ptr<PipelineInterests> m_pipeline;
};
} // namespace ndn::chunks::tests
diff --git a/tests/peek/ndnpeek.t.cpp b/tests/peek/ndnpeek.t.cpp
index 8a51b8e..0764f0c 100644
--- a/tests/peek/ndnpeek.t.cpp
+++ b/tests/peek/ndnpeek.t.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2023, Arizona Board of Regents.
+ * Copyright (c) 2014-2024, Arizona Board of Regents.
*
* This file is part of ndn-tools (Named Data Networking Essential Tools).
* See AUTHORS.md for complete list of ndn-tools authors and contributors.
@@ -24,6 +24,7 @@
#include <ndn-cxx/util/dummy-client-face.hpp>
+#include <boost/lexical_cast.hpp>
#include <boost/test/tools/output_test_stream.hpp>
namespace ndn::peek::tests {
@@ -63,13 +64,13 @@
void
initialize(const PeekOptions& opts = makeDefaultOptions())
{
- peek = make_unique<NdnPeek>(face, opts);
+ peek = std::make_unique<NdnPeek>(face, opts);
}
protected:
DummyClientFace face{m_io};
output_test_stream output;
- unique_ptr<NdnPeek> peek;
+ std::unique_ptr<NdnPeek> peek;
};
class OutputFull
@@ -232,7 +233,7 @@
BOOST_AUTO_TEST_CASE(ApplicationParameters)
{
auto options = makeDefaultOptions();
- options.applicationParameters = make_shared<Buffer>("hello", 5);
+ options.applicationParameters = std::make_shared<Buffer>("hello", 5);
initialize(options);
peek->start();
@@ -305,7 +306,7 @@
BOOST_AUTO_TEST_CASE(OversizedPacket)
{
auto options = makeDefaultOptions();
- options.applicationParameters = make_shared<Buffer>(MAX_NDN_PACKET_SIZE);
+ options.applicationParameters = std::make_shared<Buffer>(MAX_NDN_PACKET_SIZE);
initialize(options);
peek->start();
diff --git a/tests/peek/ndnpoke.t.cpp b/tests/peek/ndnpoke.t.cpp
index b20f377..1c2a2c0 100644
--- a/tests/peek/ndnpoke.t.cpp
+++ b/tests/peek/ndnpoke.t.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2023, Regents of the University of California,
+ * Copyright (c) 2014-2024, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -47,7 +47,7 @@
void
initialize(const PokeOptions& opts = makeDefaultOptions())
{
- poke = make_unique<NdnPoke>(face, m_keyChain, payload, opts);
+ poke = std::make_unique<NdnPoke>(face, m_keyChain, payload, opts);
}
static PokeOptions
@@ -61,7 +61,7 @@
protected:
DummyClientFace face{m_io, m_keyChain, {true, WANT_PREFIX_REG_REPLY}};
std::stringstream payload{"Hello, world!\n"};
- unique_ptr<NdnPoke> poke;
+ std::unique_ptr<NdnPoke> poke;
};
BOOST_AUTO_TEST_SUITE(Peek)
diff --git a/tests/ping/client/statistics-collector.t.cpp b/tests/ping/client/statistics-collector.t.cpp
index 5d3e0d3..30f2c4b 100644
--- a/tests/ping/client/statistics-collector.t.cpp
+++ b/tests/ping/client/statistics-collector.t.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2023, Arizona Board of Regents.
+ * Copyright (c) 2014-2024, Arizona Board of Regents.
*
* This file is part of ndn-tools (Named Data Networking Essential Tools).
* See AUTHORS.md for complete list of ndn-tools authors and contributors.
@@ -22,6 +22,7 @@
#include "tests/test-common.hpp"
#include <ndn-cxx/util/dummy-client-face.hpp>
+#include <cmath>
namespace ndn::ping::client::tests {
diff --git a/tests/ping/integrated.t.cpp b/tests/ping/integrated.t.cpp
index 4a85fda..caad9f8 100644
--- a/tests/ping/integrated.t.cpp
+++ b/tests/ping/integrated.t.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2015-2023, Arizona Board of Regents.
+ * Copyright (c) 2015-2024, Arizona Board of Regents.
*
* This file is part of ndn-tools (Named Data Networking Essential Tools).
* See AUTHORS.md for complete list of ndn-tools authors and contributors.
@@ -54,7 +54,7 @@
void
receive(DummyClientFace& face, const Packet& pkt)
{
- boost::asio::post(m_io, [=, &face] {
+ boost::asio::post(m_io, [&face, pkt, wantLoss = wantLoss] {
if (!wantLoss) {
face.receive(pkt);
}
@@ -88,7 +88,7 @@
serverOpts.nMaxPings = 4;
serverOpts.wantTimestamp = false;
serverOpts.payloadSize = 0;
- server = make_unique<server::PingServer>(serverFace, m_keyChain, serverOpts);
+ server = std::make_unique<server::PingServer>(serverFace, m_keyChain, serverOpts);
BOOST_REQUIRE_EQUAL(0, server->getNPings());
server->start();
@@ -101,7 +101,7 @@
clientOpts.interval = 100_ms;
clientOpts.timeout = 2_s;
clientOpts.startSeq = 1000;
- client = make_unique<client::Ping>(clientFace, clientOpts);
+ client = std::make_unique<client::Ping>(clientFace, clientOpts);
client->afterFinish.connect([this] { onFinish(); });
client->start();
@@ -121,7 +121,7 @@
serverOpts.nMaxPings = 4;
serverOpts.wantTimestamp = false;
serverOpts.payloadSize = 0;
- server = make_unique<server::PingServer>(serverFace, m_keyChain, serverOpts);
+ server = std::make_unique<server::PingServer>(serverFace, m_keyChain, serverOpts);
BOOST_REQUIRE_EQUAL(0, server->getNPings());
server->start();
@@ -134,7 +134,7 @@
clientOpts.interval = 100_ms;
clientOpts.timeout = 500_ms;
clientOpts.startSeq = 1000;
- client = make_unique<client::Ping>(clientFace, clientOpts);
+ client = std::make_unique<client::Ping>(clientFace, clientOpts);
client->afterFinish.connect([this] { onFinish(); });
client->start();
diff --git a/tests/test-common.cpp b/tests/test-common.cpp
index 89a764c..91ebcd4 100644
--- a/tests/test-common.cpp
+++ b/tests/test-common.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2023, Regents of the University of California,
+ * Copyright (c) 2014-2024, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -27,7 +27,7 @@
namespace ndn::tests {
-shared_ptr<Interest>
+std::shared_ptr<Interest>
makeInterest(const Name& name, bool canBePrefix, std::optional<time::milliseconds> lifetime,
std::optional<Interest::Nonce> nonce)
{
@@ -40,7 +40,7 @@
return interest;
}
-shared_ptr<Data>
+std::shared_ptr<Data>
makeData(const Name& name)
{
auto data = std::make_shared<Data>(name);
diff --git a/tests/test-common.hpp b/tests/test-common.hpp
index a6edb6e..6e66933 100644
--- a/tests/test-common.hpp
+++ b/tests/test-common.hpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2023, Regents of the University of California,
+ * Copyright (c) 2014-2024, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -29,48 +29,51 @@
#include "core/common.hpp"
#include "tests/boost-test.hpp"
+#include <ndn-cxx/lp/nack.hpp>
+#include <optional>
+
namespace ndn::tests {
/**
- * \brief Create an Interest
+ * \brief Create an Interest.
*/
-shared_ptr<Interest>
+std::shared_ptr<Interest>
makeInterest(const Name& name, bool canBePrefix = false,
std::optional<time::milliseconds> lifetime = std::nullopt,
std::optional<Interest::Nonce> nonce = std::nullopt);
/**
- * \brief Create a Data with a null (i.e., empty) signature
+ * \brief Create a Data with a null (i.e., empty) signature.
*
* If a "real" signature is desired, use KeyChainFixture and sign again with `m_keyChain`.
*/
-shared_ptr<Data>
+std::shared_ptr<Data>
makeData(const Name& name);
/**
- * \brief Add a null signature to \p data
+ * \brief Add a null signature to \p data.
*/
Data&
signData(Data& data);
/**
- * \brief Add a null signature to \p data
+ * \brief Add a null signature to \p data.
*/
-inline shared_ptr<Data>
-signData(shared_ptr<Data> data)
+inline std::shared_ptr<Data>
+signData(std::shared_ptr<Data> data)
{
signData(*data);
return data;
}
/**
- * \brief Create a Nack
+ * \brief Create a Nack.
*/
lp::Nack
makeNack(Interest interest, lp::NackReason reason);
/**
- * \brief Replace a name component in a packet
+ * \brief Replace a name component in a packet.
* \param[in,out] pkt the packet
* \param index the index of the name component to replace
* \param args arguments to name::Component constructor