Refactor and modernize namespace declarations
* Completely remove inline namespace v2
* Flatten some unnecessarily deep namespace nesting
* Move DummyClientFace, Segmenter, SegmentFetcher to namespace ndn
* Move all unit tests to namespace ndn::tests
Change-Id: I8bcfcf9fd669936a3277d2d5d505f765b4b05742
diff --git a/tests/unit/net/dns.t.cpp b/tests/unit/net/dns.t.cpp
index b6a24b5..ac734dd 100644
--- a/tests/unit/net/dns.t.cpp
+++ b/tests/unit/net/dns.t.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2013-2022 Regents of the University of California.
+ * Copyright (c) 2013-2023 Regents of the University of California.
*
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
*
@@ -26,10 +26,9 @@
#include <boost/asio/io_service.hpp>
-namespace ndn {
-namespace dns {
-namespace tests {
+namespace ndn::tests {
+using namespace ndn::dns;
using boost::asio::ip::address_v4;
using boost::asio::ip::address_v6;
@@ -169,6 +168,4 @@
BOOST_AUTO_TEST_SUITE_END() // TestDns
BOOST_AUTO_TEST_SUITE_END() // Net
-} // namespace tests
-} // namespace dns
-} // namespace ndn
+} // namespace ndn::tests
diff --git a/tests/unit/net/ethernet.t.cpp b/tests/unit/net/ethernet.t.cpp
index 162170b..0fc5357 100644
--- a/tests/unit/net/ethernet.t.cpp
+++ b/tests/unit/net/ethernet.t.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2018 Regents of the University of California,
+ * Copyright (c) 2014-2023 Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -29,8 +29,7 @@
#include "tests/boost-test.hpp"
-namespace ndn {
-namespace tests {
+namespace ndn::tests {
BOOST_AUTO_TEST_SUITE(Net)
BOOST_AUTO_TEST_SUITE(TestEthernet)
@@ -113,5 +112,4 @@
BOOST_AUTO_TEST_SUITE_END() // TestEthernet
BOOST_AUTO_TEST_SUITE_END() // Net
-} // namespace tests
-} // namespace ndn
+} // namespace ndn::tests
diff --git a/tests/unit/net/face-uri.t.cpp b/tests/unit/net/face-uri.t.cpp
index d21d70f..34e050e 100644
--- a/tests/unit/net/face-uri.t.cpp
+++ b/tests/unit/net/face-uri.t.cpp
@@ -34,8 +34,7 @@
#include <boost/concept_check.hpp>
-namespace ndn {
-namespace tests {
+namespace ndn::tests {
BOOST_CONCEPT_ASSERT((boost::EqualityComparable<FaceUri>));
@@ -614,5 +613,4 @@
BOOST_AUTO_TEST_SUITE_END() // TestFaceUri
BOOST_AUTO_TEST_SUITE_END() // Net
-} // namespace tests
-} // namespace ndn
+} // namespace ndn::tests
diff --git a/tests/unit/net/network-configuration-detector.cpp b/tests/unit/net/network-configuration-detector.cpp
index 84e1244..f8a8816 100644
--- a/tests/unit/net/network-configuration-detector.cpp
+++ b/tests/unit/net/network-configuration-detector.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2013-2018 Regents of the University of California.
+ * Copyright (c) 2013-2023 Regents of the University of California.
*
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
*
@@ -27,35 +27,30 @@
#include <boost/asio/ip/udp.hpp>
#include <boost/range/iterator_range_core.hpp>
-namespace ndn {
-namespace tests {
-
-bool NetworkConfigurationDetector::m_isInitialized = false;
-bool NetworkConfigurationDetector::m_hasIpv4 = false;
-bool NetworkConfigurationDetector::m_hasIpv6 = false;
+namespace ndn::tests {
bool
NetworkConfigurationDetector::hasIpv4()
{
- if (!m_isInitialized) {
+ if (!s_isInitialized) {
detect();
}
- return m_hasIpv4;
+ return s_hasIpv4;
}
bool
NetworkConfigurationDetector::hasIpv6()
{
- if (!m_isInitialized) {
+ if (!s_isInitialized) {
detect();
}
- return m_hasIpv6;
+ return s_hasIpv6;
}
void
NetworkConfigurationDetector::detect()
{
- typedef boost::asio::ip::basic_resolver<boost::asio::ip::udp> BoostResolver;
+ using BoostResolver = boost::asio::ip::basic_resolver<boost::asio::ip::udp>;
boost::asio::io_service ioService;
BoostResolver resolver(ioService);
@@ -66,22 +61,21 @@
boost::system::error_code errorCode;
BoostResolver::iterator begin = resolver.resolve(query, errorCode);
if (errorCode) {
- m_isInitialized = true;
+ s_isInitialized = true;
return;
}
BoostResolver::iterator end;
for (const auto& i : boost::make_iterator_range(begin, end)) {
if (i.endpoint().address().is_v4()) {
- m_hasIpv4 = true;
+ s_hasIpv4 = true;
}
else if (i.endpoint().address().is_v6()) {
- m_hasIpv6 = true;
+ s_hasIpv6 = true;
}
}
- m_isInitialized = true;
+ s_isInitialized = true;
}
-} // namespace tests
-} // namespace ndn
+} // namespace ndn::tests
diff --git a/tests/unit/net/network-configuration-detector.hpp b/tests/unit/net/network-configuration-detector.hpp
index 5c0c34b..7264e68 100644
--- a/tests/unit/net/network-configuration-detector.hpp
+++ b/tests/unit/net/network-configuration-detector.hpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2013-2021 Regents of the University of California.
+ * Copyright (c) 2013-2023 Regents of the University of California.
*
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
*
@@ -47,8 +47,7 @@
} \
} while (false)
-namespace ndn {
-namespace tests {
+namespace ndn::tests {
class NetworkConfigurationDetector
{
@@ -64,12 +63,11 @@
detect();
private:
- static bool m_isInitialized;
- static bool m_hasIpv4;
- static bool m_hasIpv6;
+ static inline bool s_isInitialized = false;
+ static inline bool s_hasIpv4 = false;
+ static inline bool s_hasIpv6 = false;
};
-} // namespace tests
-} // namespace ndn
+} // namespace ndn::tests
#endif // NDN_CXX_TESTS_UNIT_NET_NETWORK_CONFIGURATION_DETECTOR_HPP
diff --git a/tests/unit/net/network-monitor-stub.t.cpp b/tests/unit/net/network-monitor-stub.t.cpp
index 453a510..0ef8a9d 100644
--- a/tests/unit/net/network-monitor-stub.t.cpp
+++ b/tests/unit/net/network-monitor-stub.t.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2013-2018 Regents of the University of California.
+ * Copyright (c) 2013-2023 Regents of the University of California.
*
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
*
@@ -23,9 +23,9 @@
#include "tests/boost-test.hpp"
-namespace ndn {
-namespace net {
-namespace tests {
+namespace ndn::tests {
+
+using namespace ndn::net;
BOOST_AUTO_TEST_SUITE(Net)
BOOST_AUTO_TEST_SUITE(TestNetworkMonitorStub)
@@ -120,6 +120,4 @@
BOOST_AUTO_TEST_SUITE_END() // TestNetworkMonitorStub
BOOST_AUTO_TEST_SUITE_END() // Net
-} // namespace tests
-} // namespace net
-} // namespace ndn
+} // namespace ndn::tests
diff --git a/tests/unit/net/network-monitor.t.cpp b/tests/unit/net/network-monitor.t.cpp
index 132d0db..4515258 100644
--- a/tests/unit/net/network-monitor.t.cpp
+++ b/tests/unit/net/network-monitor.t.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2013-2018 Regents of the University of California.
+ * Copyright (c) 2013-2023 Regents of the University of California.
*
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
*
@@ -25,9 +25,9 @@
#include <boost/asio/io_service.hpp>
-namespace ndn {
-namespace net {
-namespace tests {
+namespace ndn::tests {
+
+using namespace ndn::net;
BOOST_AUTO_TEST_SUITE(Net)
BOOST_AUTO_TEST_SUITE(TestNetworkMonitor)
@@ -69,6 +69,4 @@
BOOST_AUTO_TEST_SUITE_END() // TestNetworkMonitor
BOOST_AUTO_TEST_SUITE_END() // Net
-} // namespace tests
-} // namespace net
-} // namespace ndn
+} // namespace ndn::tests