build: switch to C++17
Change-Id: Id6217b5c993f3e4726e89773128b565e5f136bb6
diff --git a/tests/chunks/consumer.t.cpp b/tests/chunks/consumer.t.cpp
index 205cfb3..e5a584f 100644
--- a/tests/chunks/consumer.t.cpp
+++ b/tests/chunks/consumer.t.cpp
@@ -39,9 +39,7 @@
#include <boost/test/output_test_stream.hpp>
#endif
-namespace ndn {
-namespace chunks {
-namespace tests {
+namespace ndn::chunks::tests {
using namespace ndn::tests;
using boost::test_tools::output_test_stream;
@@ -175,6 +173,4 @@
BOOST_AUTO_TEST_SUITE_END() // TestConsumer
BOOST_AUTO_TEST_SUITE_END() // Chunks
-} // namespace tests
-} // namespace chunks
-} // namespace ndn
+} // namespace ndn::chunks::tests
diff --git a/tests/chunks/discover-version.t.cpp b/tests/chunks/discover-version.t.cpp
index 79315cc..7d18886 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-2020, Regents of the University of California,
+ * Copyright (c) 2016-2022, Regents of the University of California,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University.
*
@@ -32,9 +32,7 @@
#include <ndn-cxx/metadata-object.hpp>
#include <ndn-cxx/util/dummy-client-face.hpp>
-namespace ndn {
-namespace chunks {
-namespace tests {
+namespace ndn::chunks::tests {
using namespace ndn::tests;
@@ -215,6 +213,4 @@
BOOST_AUTO_TEST_SUITE_END() // TestDiscoverVersion
BOOST_AUTO_TEST_SUITE_END() // Chunks
-} // namespace tests
-} // namespace chunks
-} // namespace ndn
+} // namespace ndn::chunks::tests
diff --git a/tests/chunks/pipeline-interests-aimd.t.cpp b/tests/chunks/pipeline-interests-aimd.t.cpp
index feed933..0946021 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-2020, Regents of the University of California,
+ * Copyright (c) 2016-2022, Regents of the University of California,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University.
*
@@ -29,17 +29,14 @@
#include "pipeline-interests-fixture.hpp"
-namespace ndn {
-namespace chunks {
-namespace tests {
+namespace ndn::chunks::tests {
using namespace ndn::tests;
class PipelineInterestAimdFixture : public PipelineInterestsFixture
{
-public:
+protected:
PipelineInterestAimdFixture()
- : rttEstimator(makeRttEstimatorOptions())
{
opt.isQuiet = true;
createPipeline();
@@ -70,7 +67,7 @@
protected:
Options opt;
- RttEstimatorWithStats rttEstimator;
+ RttEstimatorWithStats rttEstimator{makeRttEstimatorOptions()};
PipelineInterestsAdaptive* pipeline;
static constexpr double MARGIN = 0.001;
};
@@ -596,6 +593,4 @@
BOOST_AUTO_TEST_SUITE_END() // TestPipelineInterestsAimd
BOOST_AUTO_TEST_SUITE_END() // Chunks
-} // namespace tests
-} // namespace chunks
-} // namespace ndn
+} // namespace ndn::chunks::tests
diff --git a/tests/chunks/pipeline-interests-cubic.t.cpp b/tests/chunks/pipeline-interests-cubic.t.cpp
index fc53343..9934d9f 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-2020, Regents of the University of California,
+ * Copyright (c) 2016-2022, Regents of the University of California,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University.
*
@@ -29,17 +29,14 @@
#include "pipeline-interests-fixture.hpp"
-namespace ndn {
-namespace chunks {
-namespace tests {
+namespace ndn::chunks::tests {
using namespace ndn::tests;
class PipelineInterestCubicFixture : public PipelineInterestsFixture
{
-public:
+protected:
PipelineInterestCubicFixture()
- : rttEstimator(makeRttEstimatorOptions())
{
opt.isQuiet = true;
createPipeline();
@@ -70,7 +67,7 @@
protected:
Options opt;
- RttEstimatorWithStats rttEstimator;
+ RttEstimatorWithStats rttEstimator{makeRttEstimatorOptions()};
PipelineInterestsCubic* pipeline;
static constexpr double MARGIN = 0.001;
};
@@ -562,6 +559,4 @@
BOOST_AUTO_TEST_SUITE_END() // TestPipelineInterestsCubic
BOOST_AUTO_TEST_SUITE_END() // Chunks
-} // namespace tests
-} // namespace chunks
-} // namespace ndn
+} // namespace ndn::chunks::tests
diff --git a/tests/chunks/pipeline-interests-fixed.t.cpp b/tests/chunks/pipeline-interests-fixed.t.cpp
index 872fe4e..b4f9723 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-2020, Regents of the University of California,
+ * Copyright (c) 2016-2022, Regents of the University of California,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University.
*
@@ -29,9 +29,7 @@
#include "pipeline-interests-fixture.hpp"
-namespace ndn {
-namespace chunks {
-namespace tests {
+namespace ndn::chunks::tests {
class PipelineInterestFixedFixture : public PipelineInterestsFixture
{
@@ -298,6 +296,4 @@
BOOST_AUTO_TEST_SUITE_END() // TestPipelineInterests
BOOST_AUTO_TEST_SUITE_END() // Chunks
-} // namespace tests
-} // namespace chunks
-} // namespace ndn
+} // namespace ndn::chunks::tests
diff --git a/tests/chunks/pipeline-interests-fixture.hpp b/tests/chunks/pipeline-interests-fixture.hpp
index 643047a..ddfc82b 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-2020, Regents of the University of California,
+ * Copyright (c) 2016-2022, Regents of the University of California,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University.
*
@@ -36,9 +36,7 @@
#include <ndn-cxx/util/dummy-client-face.hpp>
-namespace ndn {
-namespace chunks {
-namespace tests {
+namespace ndn::chunks::tests {
using namespace ndn::tests;
@@ -88,8 +86,6 @@
unique_ptr<PipelineInterests> m_pipeline;
};
-} // namespace tests
-} // namespace chunks
-} // namespace ndn
+} // namespace ndn::chunks::tests
#endif // NDN_TOOLS_TESTS_CHUNKS_PIPELINE_INTERESTS_FIXTURE_HPP
diff --git a/tests/chunks/producer.t.cpp b/tests/chunks/producer.t.cpp
index ef53422..a4a280b 100644
--- a/tests/chunks/producer.t.cpp
+++ b/tests/chunks/producer.t.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2016-2021, Regents of the University of California,
+ * Copyright (c) 2016-2022, Regents of the University of California,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University.
*
@@ -37,9 +37,7 @@
#include <cmath>
#include <sstream>
-namespace ndn {
-namespace chunks {
-namespace tests {
+namespace ndn::chunks::tests {
using namespace ndn::tests;
@@ -222,6 +220,4 @@
BOOST_AUTO_TEST_SUITE_END() // TestProducer
BOOST_AUTO_TEST_SUITE_END() // Chunks
-} // namespace tests
-} // namespace chunks
-} // namespace ndn
+} // namespace ndn::chunks::tests
diff --git a/tests/clock-fixture.cpp b/tests/clock-fixture.cpp
index 564f128..f138bda 100644
--- a/tests/clock-fixture.cpp
+++ b/tests/clock-fixture.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,
@@ -25,8 +25,7 @@
#include "tests/clock-fixture.hpp"
-namespace ndn {
-namespace tests {
+namespace ndn::tests {
ClockFixture::ClockFixture()
: m_steadyClock(make_shared<time::UnitTestSteadyClock>())
@@ -56,5 +55,4 @@
}
}
-} // namespace tests
-} // namespace ndn
+} // namespace ndn::tests
diff --git a/tests/clock-fixture.hpp b/tests/clock-fixture.hpp
index f05babe..27bf167 100644
--- a/tests/clock-fixture.hpp
+++ b/tests/clock-fixture.hpp
@@ -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,
@@ -28,8 +28,7 @@
#include <ndn-cxx/util/time-unit-test-clock.hpp>
-namespace ndn {
-namespace tests {
+namespace ndn::tests {
/** \brief A test fixture that overrides steady clock and system clock.
*/
@@ -83,7 +82,6 @@
shared_ptr<time::UnitTestSystemClock> m_systemClock;
};
-} // namespace tests
-} // namespace ndn
+} // namespace ndn::tests
#endif // NDN_TOOLS_TESTS_CLOCK_FIXTURE_HPP
diff --git a/tests/dump/ndndump.t.cpp b/tests/dump/ndndump.t.cpp
index 217dc10..263691e 100644
--- a/tests/dump/ndndump.t.cpp
+++ b/tests/dump/ndndump.t.cpp
@@ -39,9 +39,7 @@
#include <ndn-cxx/lp/packet.hpp>
#include <ndn-cxx/net/ethernet.hpp>
-namespace ndn {
-namespace dump {
-namespace tests {
+namespace ndn::dump::tests {
namespace endian = boost::endian;
using namespace ndn::tests;
@@ -157,15 +155,11 @@
NdnDump dump;
boost::test_tools::output_test_stream output;
- static const uint16_t s_ethertypeNdn;
- static const uint16_t s_ethertypeIp4;
- static const uint16_t s_ethertypeIp6;
+ static inline const uint16_t s_ethertypeNdn = endian::native_to_big(ethernet::ETHERTYPE_NDN);
+ static inline const uint16_t s_ethertypeIp4 = endian::native_to_big(uint16_t(ETHERTYPE_IP));
+ static inline const uint16_t s_ethertypeIp6 = endian::native_to_big(uint16_t(ETHERTYPE_IPV6));
};
-const uint16_t NdnDumpFixture::s_ethertypeNdn = endian::native_to_big(ethernet::ETHERTYPE_NDN);
-const uint16_t NdnDumpFixture::s_ethertypeIp4 = endian::native_to_big(uint16_t(ETHERTYPE_IP));
-const uint16_t NdnDumpFixture::s_ethertypeIp6 = endian::native_to_big(uint16_t(ETHERTYPE_IPV6));
-
BOOST_AUTO_TEST_SUITE(Dump)
BOOST_FIXTURE_TEST_SUITE(TestNdnDump, NdnDumpFixture)
@@ -500,6 +494,4 @@
BOOST_AUTO_TEST_SUITE_END() // TestNdnDump
BOOST_AUTO_TEST_SUITE_END() // Dump
-} // namespace tests
-} // namespace dump
-} // namespace ndn
+} // namespace ndn::dump::tests
diff --git a/tests/global-configuration.cpp b/tests/global-configuration.cpp
index f0c136a..49a330c 100644
--- a/tests/global-configuration.cpp
+++ b/tests/global-configuration.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.
*
* This file is part of ndn-tools (Named Data Networking Essential Tools).
* See AUTHORS.md for complete list of ndn-tools authors and contributors.
@@ -25,8 +25,7 @@
#include <fstream>
#include <stdlib.h>
-namespace ndn {
-namespace tests {
+namespace ndn::tests {
class GlobalConfiguration
{
@@ -68,5 +67,4 @@
BOOST_GLOBAL_FIXTURE(GlobalConfiguration)
#endif
-} // namespace tests
-} // namespace ndn
+} // namespace ndn::tests
diff --git a/tests/io-fixture.hpp b/tests/io-fixture.hpp
index 881065c..71b098a 100644
--- a/tests/io-fixture.hpp
+++ b/tests/io-fixture.hpp
@@ -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,
@@ -30,8 +30,7 @@
#include <boost/asio/io_service.hpp>
-namespace ndn {
-namespace tests {
+namespace ndn::tests {
class IoFixture : public ClockFixture
{
@@ -53,7 +52,6 @@
boost::asio::io_service m_io;
};
-} // namespace tests
-} // namespace ndn
+} // namespace ndn::tests
#endif // NDN_TOOLS_TESTS_IO_FIXTURE_HPP
diff --git a/tests/key-chain-fixture.cpp b/tests/key-chain-fixture.cpp
index 283c7bc..59098d7 100644
--- a/tests/key-chain-fixture.cpp
+++ b/tests/key-chain-fixture.cpp
@@ -23,8 +23,7 @@
#include <boost/filesystem.hpp>
-namespace ndn {
-namespace tests {
+namespace ndn::tests {
using namespace ndn::security;
@@ -113,5 +112,4 @@
return saveIdentityCert(id, filename);
}
-} // namespace tests
-} // namespace ndn
+} // namespace ndn::tests
diff --git a/tests/key-chain-fixture.hpp b/tests/key-chain-fixture.hpp
index f86de19..8c09170 100644
--- a/tests/key-chain-fixture.hpp
+++ b/tests/key-chain-fixture.hpp
@@ -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.
*
* This file is part of ndn-tools (Named Data Networking Essential Tools).
* See AUTHORS.md for complete list of ndn-tools authors and contributors.
@@ -23,8 +23,7 @@
#include <ndn-cxx/security/key-chain.hpp>
#include <ndn-cxx/security/signing-helpers.hpp>
-namespace ndn {
-namespace tests {
+namespace ndn::tests {
/**
* @brief A fixture providing an in-memory KeyChain.
@@ -87,7 +86,6 @@
std::vector<std::string> m_certFiles;
};
-} // namespace tests
-} // namespace ndn
+} // namespace ndn::tests
#endif // NDN_TOOLS_TESTS_KEY_CHAIN_FIXTURE_HPP
diff --git a/tests/peek/ndnpeek.t.cpp b/tests/peek/ndnpeek.t.cpp
index dfb8768..b9631f7 100644
--- a/tests/peek/ndnpeek.t.cpp
+++ b/tests/peek/ndnpeek.t.cpp
@@ -31,9 +31,7 @@
#include <boost/test/output_test_stream.hpp>
#endif
-namespace ndn {
-namespace peek {
-namespace tests {
+namespace ndn::peek::tests {
using namespace ndn::tests;
using boost::test_tools::output_test_stream;
@@ -324,6 +322,4 @@
BOOST_AUTO_TEST_SUITE_END() // TestNdnPeek
BOOST_AUTO_TEST_SUITE_END() // Peek
-} // namespace tests
-} // namespace peek
-} // namespace ndn
+} // namespace ndn::peek::tests
diff --git a/tests/peek/ndnpoke.t.cpp b/tests/peek/ndnpoke.t.cpp
index 617b516..14fe305 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-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,
@@ -31,9 +31,7 @@
#include <ndn-cxx/util/dummy-client-face.hpp>
-namespace ndn {
-namespace peek {
-namespace tests {
+namespace ndn::peek::tests {
using namespace ndn::tests;
@@ -256,6 +254,4 @@
BOOST_AUTO_TEST_SUITE_END() // TestNdnPoke
BOOST_AUTO_TEST_SUITE_END() // Peek
-} // namespace tests
-} // namespace peek
-} // namespace ndn
+} // namespace ndn::peek::tests
diff --git a/tests/ping/client/ping.t.cpp b/tests/ping/client/ping.t.cpp
index a0eb163..a008271 100644
--- a/tests/ping/client/ping.t.cpp
+++ b/tests/ping/client/ping.t.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2021, Arizona Board of Regents.
+ * Copyright (c) 2014-2022, 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,10 +24,7 @@
#include <ndn-cxx/util/dummy-client-face.hpp>
-namespace ndn {
-namespace ping {
-namespace client {
-namespace tests {
+namespace ndn::ping::client::tests {
using namespace ndn::tests;
@@ -96,7 +93,4 @@
BOOST_AUTO_TEST_SUITE_END() // TestClient
BOOST_AUTO_TEST_SUITE_END() // Ping
-} // namespace tests
-} // namespace client
-} // namespace ping
-} // namespace ndn
+} // namespace ndn::ping::client::tests
diff --git a/tests/ping/client/statistics-collector.t.cpp b/tests/ping/client/statistics-collector.t.cpp
index 270c576..9d5423a 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-2016, Arizona Board of Regents.
+/*
+ * Copyright (c) 2014-2022, 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.
@@ -20,46 +20,34 @@
#include "tools/ping/client/statistics-collector.hpp"
#include "tests/test-common.hpp"
+
#include <ndn-cxx/util/dummy-client-face.hpp>
-namespace ndn {
-namespace ping {
-namespace client {
-namespace tests {
-
-using namespace ndn::tests;
+namespace ndn::ping::client::tests {
class StatisticsCollectorFixture
{
-protected:
- StatisticsCollectorFixture()
- : pingOptions(makeOptions())
- , pingProgram(face, pingOptions)
- , sc(pingProgram, pingOptions)
- {
- }
-
private:
static Options
makeOptions()
{
Options opt;
- opt.prefix = "ndn:/ping-prefix";
+ opt.prefix = "/ping-prefix";
opt.shouldAllowStaleData = false;
opt.shouldGenerateRandomSeq = false;
opt.shouldPrintTimestamp = false;
opt.nPings = 5;
- opt.interval = time::milliseconds(100);
- opt.timeout = time::milliseconds(2000);
+ opt.interval = 100_ms;
+ opt.timeout = 2_s;
opt.startSeq = 1;
return opt;
}
protected:
util::DummyClientFace face;
- Options pingOptions;
- Ping pingProgram;
- StatisticsCollector sc;
+ Options pingOptions{makeOptions()};
+ Ping pingProgram{face, pingOptions};
+ StatisticsCollector sc{pingProgram, pingOptions};
};
BOOST_AUTO_TEST_SUITE(Ping)
@@ -211,7 +199,4 @@
BOOST_AUTO_TEST_SUITE_END() // TestStatisticsCollector
BOOST_AUTO_TEST_SUITE_END() // Ping
-} // namespace tests
-} // namespace client
-} // namespace ping
-} // namespace ndn
+} // namespace ndn::ping::client::tests
diff --git a/tests/ping/integrated.t.cpp b/tests/ping/integrated.t.cpp
index eafc52b..0b95ba3 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-2020, Arizona Board of Regents.
+ * Copyright (c) 2015-2022, 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.
@@ -26,53 +26,60 @@
#include <ndn-cxx/util/dummy-client-face.hpp>
-namespace ndn {
-namespace ping {
-namespace tests {
+namespace ndn::ping::tests {
using namespace ndn::tests;
class PingIntegratedFixture : public IoFixture, public KeyChainFixture
{
-public:
+protected:
PingIntegratedFixture()
- : serverFace(m_io, m_keyChain, {false, true})
- , clientFace(m_io, m_keyChain, {false, true})
- , wantLoss(false)
{
- serverFace.onSendInterest.connect([this] (const Interest& interest) {
- m_io.post([=] { if (!wantLoss) { clientFace.receive(interest); } });
+ serverFace.onSendInterest.connect([this] (const auto& interest) {
+ receive(clientFace, interest);
});
- clientFace.onSendInterest.connect([this] (const Interest& interest) {
- m_io.post([=] { if (!wantLoss) { serverFace.receive(interest); } });
+ clientFace.onSendInterest.connect([this] (const auto& interest) {
+ receive(serverFace, interest);
});
- serverFace.onSendData.connect([this] (const Data& data) {
- m_io.post([=] { if (!wantLoss) { clientFace.receive(data); } });
+ serverFace.onSendData.connect([this] (const auto& data) {
+ receive(clientFace, data);
});
- clientFace.onSendData.connect([this] (const Data& data) {
- m_io.post([=] { if (!wantLoss) { serverFace.receive(data); } });
+ clientFace.onSendData.connect([this] (const auto& data) {
+ receive(serverFace, data);
});
}
- void onFinish()
+ template<typename Packet>
+ void
+ receive(util::DummyClientFace& face, const Packet& pkt)
+ {
+ m_io.post([=, &face] {
+ if (!wantLoss) {
+ face.receive(pkt);
+ }
+ });
+ }
+
+ void
+ onFinish()
{
serverFace.shutdown();
clientFace.shutdown();
m_io.stop();
}
-public:
- util::DummyClientFace serverFace;
- util::DummyClientFace clientFace;
+protected:
+ util::DummyClientFace serverFace{m_io, m_keyChain, {false, true}};
+ util::DummyClientFace clientFace{m_io, m_keyChain, {false, true}};
std::unique_ptr<server::PingServer> server;
std::unique_ptr<client::Ping> client;
- bool wantLoss;
+ bool wantLoss = false;
};
BOOST_AUTO_TEST_SUITE(Ping)
-BOOST_AUTO_TEST_SUITE(TestIntegrated)
+BOOST_FIXTURE_TEST_SUITE(TestIntegrated, PingIntegratedFixture)
-BOOST_FIXTURE_TEST_CASE(Normal, PingIntegratedFixture)
+BOOST_AUTO_TEST_CASE(Normal)
{
server::Options serverOpts;
serverOpts.prefix = "ndn:/test-prefix";
@@ -103,7 +110,7 @@
BOOST_CHECK_EQUAL(4, server->getNPings());
}
-BOOST_FIXTURE_TEST_CASE(Timeout, PingIntegratedFixture)
+BOOST_AUTO_TEST_CASE(Timeout)
{
wantLoss = true;
@@ -139,6 +146,4 @@
BOOST_AUTO_TEST_SUITE_END() // TestIntegrated
BOOST_AUTO_TEST_SUITE_END() // Ping
-} // namespace tests
-} // namespace ping
-} // namespace ndn
+} // namespace ndn::ping::tests
diff --git a/tests/ping/server/ping-server.t.cpp b/tests/ping/server/ping-server.t.cpp
index e01d3d7..b5c9948 100644
--- a/tests/ping/server/ping-server.t.cpp
+++ b/tests/ping/server/ping-server.t.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2021, Arizona Board of Regents.
+ * Copyright (c) 2014-2022, 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.
@@ -25,26 +25,13 @@
#include <ndn-cxx/util/dummy-client-face.hpp>
-namespace ndn {
-namespace ping {
-namespace server {
-namespace tests {
+namespace ndn::ping::server::tests {
using namespace ndn::tests;
-BOOST_AUTO_TEST_SUITE(Ping)
-BOOST_AUTO_TEST_SUITE(TestServer)
-
class PingServerFixture : public IoFixture, public KeyChainFixture
{
protected:
- PingServerFixture()
- : face(m_io, m_keyChain, {false, true})
- , pingOptions(makeOptions())
- , pingServer(face, m_keyChain, pingOptions)
- {
- }
-
Interest
makePingInterest(int seq) const
{
@@ -53,7 +40,6 @@
.append(to_string(seq));
return Interest(name)
- .setCanBePrefix(false)
.setMustBeFresh(true)
.setInterestLifetime(2_s);
}
@@ -73,11 +59,14 @@
}
protected:
- util::DummyClientFace face;
- Options pingOptions;
- PingServer pingServer;
+ util::DummyClientFace face{m_io, m_keyChain, {false, true}};
+ Options pingOptions{makeOptions()};
+ PingServer pingServer{face, m_keyChain, pingOptions};
};
+BOOST_AUTO_TEST_SUITE(Ping)
+BOOST_AUTO_TEST_SUITE(TestServer)
+
BOOST_FIXTURE_TEST_CASE(Receive, PingServerFixture)
{
BOOST_TEST(pingServer.getNPings() == 0);
@@ -96,7 +85,4 @@
BOOST_AUTO_TEST_SUITE_END() // TestServer
BOOST_AUTO_TEST_SUITE_END() // Ping
-} // namespace tests
-} // namespace server
-} // namespace ping
-} // namespace ndn
+} // namespace ndn::ping::server::tests
diff --git a/tests/test-case.t.cpp.sample b/tests/test-case.t.cpp.sample
index 8f6584b..a2f74c1 100644
--- a/tests/test-case.t.cpp.sample
+++ b/tests/test-case.t.cpp.sample
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2020 Arizona Board of Regents.
+ * Copyright (c) 2014-2022 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.
@@ -26,15 +26,14 @@
#include "tests/io-fixture.hpp" // optional, for IoFixture
//#include "tests/key-chain-fixture.hpp" // optional, for KeyChainFixture
-namespace ndn {
-namespace tool_name {
-namespace tests {
// Unit tests should go inside the ndn::tool_name::tests namespace.
+namespace ndn::tool_name::tests {
// Common fixtures in ndn::tests can be imported if needed.
using namespace ndn::tests;
-// See https://redmine.named-data.net/projects/nfd/wiki/UnitTesting for a guide on how to name a test suite.
+// See https://redmine.named-data.net/projects/nfd/wiki/UnitTesting
+// for a guide on how to name a test suite.
BOOST_AUTO_TEST_SUITE(TestSkeleton)
BOOST_AUTO_TEST_CASE(Test1)
@@ -55,8 +54,6 @@
advanceClocks(500_ms);
}
-BOOST_AUTO_TEST_SUITE_END()
+BOOST_AUTO_TEST_SUITE_END() // TestSkeleton
-} // namespace tests
-} // namespace tool_name
-} // namespace ndn
+} // namespace ndn::tool_name::tests
diff --git a/tests/test-common.cpp b/tests/test-common.cpp
index 98fa188..6a994b0 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-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,
@@ -25,8 +25,7 @@
#include "tests/test-common.hpp"
-namespace ndn {
-namespace tests {
+namespace ndn::tests {
shared_ptr<Interest>
makeInterest(const Name& name, bool canBePrefix, optional<time::milliseconds> lifetime,
@@ -65,5 +64,4 @@
return nack;
}
-} // namespace tests
-} // namespace ndn
+} // namespace ndn::tests
diff --git a/tests/test-common.hpp b/tests/test-common.hpp
index 5fa2a8d..5ff903a 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-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,
@@ -29,8 +29,7 @@
#include "core/common.hpp"
#include "tests/boost-test.hpp"
-namespace ndn {
-namespace tests {
+namespace ndn::tests {
/**
* \brief Create an Interest
@@ -85,7 +84,6 @@
pkt.setName(name);
}
-} // namespace tests
-} // namespace ndn
+} // namespace ndn::tests
#endif // NDN_TOOLS_TESTS_TEST_COMMON_HPP