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/security/pib/certificate-container.t.cpp b/tests/unit/security/pib/certificate-container.t.cpp
index b1d4343..ecfd0b9 100644
--- a/tests/unit/security/pib/certificate-container.t.cpp
+++ b/tests/unit/security/pib/certificate-container.t.cpp
@@ -26,15 +26,13 @@
#include "tests/boost-test.hpp"
#include "tests/unit/security/pib/pib-data-fixture.hpp"
-namespace ndn {
-namespace security {
-namespace pib {
-namespace tests {
+namespace ndn::tests {
+
+using namespace ndn::security::pib;
NDN_CXX_ASSERT_FORWARD_ITERATOR(CertificateContainer::const_iterator);
BOOST_AUTO_TEST_SUITE(Security)
-BOOST_AUTO_TEST_SUITE(Pib)
BOOST_FIXTURE_TEST_SUITE(TestCertificateContainer, PibDataFixture)
BOOST_AUTO_TEST_CASE(AddGetRemove)
@@ -72,7 +70,7 @@
BOOST_CHECK_EQUAL(cert1, id1Key1Cert1);
BOOST_CHECK_EQUAL(cert2, id1Key1Cert2);
Name id1Key1Cert3Name = Name(id1Key1Name).append("issuer").appendVersion(3);
- BOOST_CHECK_THROW(container.get(id1Key1Cert3Name), pib::Pib::Error);
+ BOOST_CHECK_THROW(container.get(id1Key1Cert3Name), Pib::Error);
}
{
@@ -158,10 +156,6 @@
}
BOOST_AUTO_TEST_SUITE_END() // TestCertificateContainer
-BOOST_AUTO_TEST_SUITE_END() // Pib
BOOST_AUTO_TEST_SUITE_END() // Security
-} // namespace tests
-} // namespace pib
-} // namespace security
-} // namespace ndn
+} // namespace ndn::tests
diff --git a/tests/unit/security/pib/identity-container.t.cpp b/tests/unit/security/pib/identity-container.t.cpp
index ea97da0..81f9ad0 100644
--- a/tests/unit/security/pib/identity-container.t.cpp
+++ b/tests/unit/security/pib/identity-container.t.cpp
@@ -26,15 +26,13 @@
#include "tests/boost-test.hpp"
#include "tests/unit/security/pib/pib-data-fixture.hpp"
-namespace ndn {
-namespace security {
-namespace pib {
-namespace tests {
+namespace ndn::tests {
+
+using namespace ndn::security::pib;
NDN_CXX_ASSERT_FORWARD_ITERATOR(IdentityContainer::const_iterator);
BOOST_AUTO_TEST_SUITE(Security)
-BOOST_AUTO_TEST_SUITE(Pib)
BOOST_FIXTURE_TEST_SUITE(TestIdentityContainer, PibDataFixture)
BOOST_AUTO_TEST_CASE(AddGetRemove)
@@ -74,7 +72,7 @@
Identity identity2 = container.get(id2);
BOOST_CHECK_EQUAL(identity1.getName(), id1);
BOOST_CHECK_EQUAL(identity2.getName(), id2);
- BOOST_CHECK_THROW(container.get(Name("/non-existing")), pib::Pib::Error);
+ BOOST_CHECK_THROW(container.get(Name("/non-existing")), Pib::Error);
}
{
@@ -150,10 +148,6 @@
}
BOOST_AUTO_TEST_SUITE_END() // TestIdentityContainer
-BOOST_AUTO_TEST_SUITE_END() // Pib
BOOST_AUTO_TEST_SUITE_END() // Security
-} // namespace tests
-} // namespace pib
-} // namespace security
-} // namespace ndn
+} // namespace ndn::tests
diff --git a/tests/unit/security/pib/identity.t.cpp b/tests/unit/security/pib/identity.t.cpp
index be2d03b..70252d9 100644
--- a/tests/unit/security/pib/identity.t.cpp
+++ b/tests/unit/security/pib/identity.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).
*
@@ -25,13 +25,11 @@
#include "tests/boost-test.hpp"
#include "tests/unit/security/pib/pib-data-fixture.hpp"
-namespace ndn {
-namespace security {
-namespace pib {
-namespace tests {
+namespace ndn::tests {
+
+using namespace ndn::security::pib;
BOOST_AUTO_TEST_SUITE(Security)
-BOOST_AUTO_TEST_SUITE(Pib)
BOOST_FIXTURE_TEST_SUITE(TestIdentity, PibDataFixture)
BOOST_AUTO_TEST_CASE(ValidityChecking)
@@ -41,7 +39,7 @@
BOOST_TEST(id == Identity());
BOOST_CHECK_THROW(id.getName(), std::domain_error);
- auto impl = std::make_shared<detail::IdentityImpl>(id1, makePibWithIdentity(id1));
+ auto impl = std::make_shared<IdentityImpl>(id1, makePibWithIdentity(id1));
id = Identity(impl);
BOOST_TEST(id);
BOOST_TEST(id != Identity());
@@ -52,12 +50,12 @@
BOOST_CHECK_THROW(id.getName(), std::domain_error);
}
-// pib::Identity is a wrapper of pib::detail::IdentityImpl. Since the functionality
-// of IdentityImpl is already tested in identity-impl.t.cpp, we only test the shared
-// property of pib::Identity in this test case.
+// pib::Identity is a wrapper of pib::IdentityImpl. Since the functionality
+// of IdentityImpl is already tested in identity-impl.t.cpp, we only test
+// the shared property of pib::Identity in this test case.
BOOST_AUTO_TEST_CASE(SharedImpl)
{
- auto impl = std::make_shared<detail::IdentityImpl>(id1, makePibWithIdentity(id1));
+ auto impl = std::make_shared<IdentityImpl>(id1, makePibWithIdentity(id1));
Identity identity1(impl);
Identity identity2(impl);
@@ -66,22 +64,18 @@
BOOST_TEST(Identity() != identity2);
BOOST_TEST(Identity() == Identity());
- BOOST_CHECK_THROW(identity2.getKey(id1Key1Name), pib::Pib::Error);
+ BOOST_CHECK_THROW(identity2.getKey(id1Key1Name), Pib::Error);
identity1.addKey(id1Key1, id1Key1Name);
BOOST_TEST(identity2.getKey(id1Key1Name));
identity2.removeKey(id1Key1Name);
- BOOST_CHECK_THROW(identity1.getKey(id1Key1Name), pib::Pib::Error);
+ BOOST_CHECK_THROW(identity1.getKey(id1Key1Name), Pib::Error);
identity1.setDefaultKey(id1Key1, id1Key1Name);
BOOST_TEST(identity2.getDefaultKey().getName() == id1Key1Name);
}
BOOST_AUTO_TEST_SUITE_END() // TestIdentity
-BOOST_AUTO_TEST_SUITE_END() // Pib
BOOST_AUTO_TEST_SUITE_END() // Security
-} // namespace tests
-} // namespace pib
-} // namespace security
-} // namespace ndn
+} // namespace ndn::tests
diff --git a/tests/unit/security/pib/impl/identity-impl.t.cpp b/tests/unit/security/pib/impl/identity-impl.t.cpp
index 3f38e0e..6b44993 100644
--- a/tests/unit/security/pib/impl/identity-impl.t.cpp
+++ b/tests/unit/security/pib/impl/identity-impl.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).
*
@@ -24,18 +24,13 @@
#include "tests/boost-test.hpp"
#include "tests/unit/security/pib/pib-data-fixture.hpp"
-namespace ndn {
-namespace security {
-namespace pib {
-namespace detail {
-namespace tests {
+namespace ndn::tests {
+
+using namespace ndn::security::pib;
BOOST_AUTO_TEST_SUITE(Security)
-BOOST_AUTO_TEST_SUITE(Pib)
-using pib::Pib;
-
-class IdentityImplFixture : public pib::tests::PibDataFixture
+class IdentityImplFixture : public PibDataFixture
{
protected:
const shared_ptr<PibImpl> pibImpl = makePibWithIdentity(id1);
@@ -136,11 +131,6 @@
}
BOOST_AUTO_TEST_SUITE_END() // TestIdentityImpl
-BOOST_AUTO_TEST_SUITE_END() // Pib
BOOST_AUTO_TEST_SUITE_END() // Security
-} // namespace tests
-} // namespace detail
-} // namespace pib
-} // namespace security
-} // namespace ndn
+} // namespace ndn::tests
diff --git a/tests/unit/security/pib/impl/key-impl.t.cpp b/tests/unit/security/pib/impl/key-impl.t.cpp
index 4cb960a..940974b 100644
--- a/tests/unit/security/pib/impl/key-impl.t.cpp
+++ b/tests/unit/security/pib/impl/key-impl.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).
*
@@ -25,18 +25,13 @@
#include "tests/key-chain-fixture.hpp"
#include "tests/unit/security/pib/pib-data-fixture.hpp"
-namespace ndn {
-namespace security {
-namespace pib {
-namespace detail {
-namespace tests {
+namespace ndn::tests {
+
+using namespace ndn::security::pib;
BOOST_AUTO_TEST_SUITE(Security)
-BOOST_AUTO_TEST_SUITE(Pib)
-using pib::Pib;
-
-class KeyImplFixture : public pib::tests::PibDataFixture
+class KeyImplFixture : public PibDataFixture
{
protected:
const shared_ptr<PibImpl> pibImpl = makePibWithKey(id1Key1Name, id1Key1);
@@ -114,8 +109,7 @@
BOOST_CHECK_THROW(key11.getDefaultCertificate(), Pib::Error);
}
-class ReplaceFixture : public ndn::tests::KeyChainFixture,
- public KeyImplFixture
+class ReplaceFixture : public KeyChainFixture, public KeyImplFixture
{
};
@@ -126,8 +120,8 @@
auto otherCert = id1Key1Cert1;
SignatureInfo info;
- info.setValidityPeriod(ValidityPeriod::makeRelative(-1_s, 10_s));
- m_keyChain.sign(otherCert, SigningInfo().setSignatureInfo(info));
+ info.setValidityPeriod(security::ValidityPeriod::makeRelative(-1_s, 10_s));
+ m_keyChain.sign(otherCert, security::SigningInfo().setSignatureInfo(info));
BOOST_TEST(otherCert.getName() == id1Key1Cert1.getName());
BOOST_TEST(otherCert.getContent() == id1Key1Cert1.getContent());
BOOST_TEST(otherCert != id1Key1Cert1);
@@ -162,11 +156,6 @@
}
BOOST_AUTO_TEST_SUITE_END() // TestKeyImpl
-BOOST_AUTO_TEST_SUITE_END() // Pib
BOOST_AUTO_TEST_SUITE_END() // Security
-} // namespace tests
-} // namespace detail
-} // namespace pib
-} // namespace security
-} // namespace ndn
+} // namespace ndn::tests
diff --git a/tests/unit/security/pib/key-container.t.cpp b/tests/unit/security/pib/key-container.t.cpp
index b126bc2..84a4d3f 100644
--- a/tests/unit/security/pib/key-container.t.cpp
+++ b/tests/unit/security/pib/key-container.t.cpp
@@ -26,15 +26,13 @@
#include "tests/boost-test.hpp"
#include "tests/unit/security/pib/pib-data-fixture.hpp"
-namespace ndn {
-namespace security {
-namespace pib {
-namespace tests {
+namespace ndn::tests {
+
+using namespace ndn::security::pib;
NDN_CXX_ASSERT_FORWARD_ITERATOR(KeyContainer::const_iterator);
BOOST_AUTO_TEST_SUITE(Security)
-BOOST_AUTO_TEST_SUITE(Pib)
BOOST_FIXTURE_TEST_SUITE(TestKeyContainer, PibDataFixture)
BOOST_AUTO_TEST_CASE(AddGetRemove)
@@ -79,8 +77,8 @@
BOOST_TEST(key1.getPublicKey() == id1Key1, boost::test_tools::per_element());
BOOST_CHECK_EQUAL(key2.getName(), id1Key2Name);
BOOST_TEST(key2.getPublicKey() == id1Key2, boost::test_tools::per_element());
- Name id1Key3Name = constructKeyName(id1, name::Component("non-existing-id"));
- BOOST_CHECK_THROW(container.get(id1Key3Name), pib::Pib::Error);
+ Name id1Key3Name = security::constructKeyName(id1, name::Component("non-existing-id"));
+ BOOST_CHECK_THROW(container.get(id1Key3Name), Pib::Error);
}
{
@@ -167,10 +165,6 @@
}
BOOST_AUTO_TEST_SUITE_END() // TestKeyContainer
-BOOST_AUTO_TEST_SUITE_END() // Pib
BOOST_AUTO_TEST_SUITE_END() // Security
-} // namespace tests
-} // namespace pib
-} // namespace security
-} // namespace ndn
+} // namespace ndn::tests
diff --git a/tests/unit/security/pib/key.t.cpp b/tests/unit/security/pib/key.t.cpp
index 4d1da0c..5273436 100644
--- a/tests/unit/security/pib/key.t.cpp
+++ b/tests/unit/security/pib/key.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).
*
@@ -25,13 +25,11 @@
#include "tests/boost-test.hpp"
#include "tests/unit/security/pib/pib-data-fixture.hpp"
-namespace ndn {
-namespace security {
-namespace pib {
-namespace tests {
+namespace ndn::tests {
+
+using namespace ndn::security::pib;
BOOST_AUTO_TEST_SUITE(Security)
-BOOST_AUTO_TEST_SUITE(Pib)
BOOST_FIXTURE_TEST_SUITE(TestKey, PibDataFixture)
BOOST_AUTO_TEST_CASE(ValidityChecking)
@@ -41,8 +39,7 @@
BOOST_TEST(key == Key());
BOOST_CHECK_THROW(key.getName(), std::domain_error);
- auto impl = std::make_shared<detail::KeyImpl>(id1Key1Name, id1Key1,
- makePibWithKey(id1Key1Name, id1Key1));
+ auto impl = std::make_shared<KeyImpl>(id1Key1Name, id1Key1, makePibWithKey(id1Key1Name, id1Key1));
key = Key(impl);
BOOST_TEST(key);
BOOST_TEST(key != Key());
@@ -53,13 +50,12 @@
BOOST_CHECK_THROW(key.getName(), std::domain_error);
}
-// pib::Key is a wrapper of pib::detail::KeyImpl. Since the functionality of KeyImpl is
-// already tested in key-impl.t.cpp, we only test the shared property of pib::Key in
-// this test case.
+// pib::Key is a wrapper of pib::KeyImpl. Since the functionality of KeyImpl is
+// already tested in key-impl.t.cpp, we only test the shared property of pib::Key
+// in this test case.
BOOST_AUTO_TEST_CASE(SharedImpl)
{
- auto keyImpl = std::make_shared<detail::KeyImpl>(id1Key1Name, id1Key1,
- makePibWithKey(id1Key1Name, id1Key1));
+ auto keyImpl = std::make_shared<KeyImpl>(id1Key1Name, id1Key1, makePibWithKey(id1Key1Name, id1Key1));
Key key1(keyImpl);
Key key2(keyImpl);
@@ -68,12 +64,12 @@
BOOST_TEST(Key() != key2);
BOOST_TEST(Key() == Key());
- BOOST_CHECK_THROW(key2.getCertificate(id1Key1Cert1.getName()), pib::Pib::Error);
+ BOOST_CHECK_THROW(key2.getCertificate(id1Key1Cert1.getName()), Pib::Error);
key1.addCertificate(id1Key1Cert1);
BOOST_TEST(key2.getCertificate(id1Key1Cert1.getName()) == id1Key1Cert1);
key2.removeCertificate(id1Key1Cert1.getName());
- BOOST_CHECK_THROW(key1.getCertificate(id1Key1Cert1.getName()), pib::Pib::Error);
+ BOOST_CHECK_THROW(key1.getCertificate(id1Key1Cert1.getName()), Pib::Error);
key1.setDefaultCertificate(id1Key1Cert1);
BOOST_TEST(key2.getDefaultCertificate() == id1Key1Cert1);
@@ -81,6 +77,10 @@
BOOST_AUTO_TEST_CASE(Helpers)
{
+ using ndn::security::constructKeyName;
+ using ndn::security::isValidKeyName;
+ using ndn::security::extractIdentityFromKeyName;
+
BOOST_CHECK_EQUAL(constructKeyName("/hello", name::Component("world")), "/hello/KEY/world");
BOOST_CHECK_EQUAL(isValidKeyName("/hello"), false);
@@ -98,10 +98,6 @@
}
BOOST_AUTO_TEST_SUITE_END() // TestKey
-BOOST_AUTO_TEST_SUITE_END() // Pib
BOOST_AUTO_TEST_SUITE_END() // Security
-} // namespace tests
-} // namespace pib
-} // namespace security
-} // namespace ndn
+} // namespace ndn::tests
diff --git a/tests/unit/security/pib/pib-data-fixture.cpp b/tests/unit/security/pib/pib-data-fixture.cpp
index 488d11e..dde1d8b 100644
--- a/tests/unit/security/pib/pib-data-fixture.cpp
+++ b/tests/unit/security/pib/pib-data-fixture.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).
*
@@ -30,10 +30,10 @@
// #include <iostream>
-namespace ndn {
-namespace security {
-namespace pib {
-namespace tests {
+namespace ndn::tests {
+
+using namespace ndn::security;
+using namespace ndn::security::pib;
// class TestCertDataGenerator
// {
@@ -95,8 +95,8 @@
// }
// private:
-// pib::PibMemory pib;
-// Tpm tpm{"test", "test", make_unique<tpm::BackEndMem>()};
+// PibMemory pib;
+// Tpm tpm{"test:test", make_unique<tpm::BackEndMem>()};
// };
// // The test data can be generated using this test case
@@ -414,7 +414,4 @@
return pib;
}
-} // namespace tests
-} // namespace pib
-} // namespace security
-} // namespace ndn
+} // namespace ndn::tests
diff --git a/tests/unit/security/pib/pib-data-fixture.hpp b/tests/unit/security/pib/pib-data-fixture.hpp
index 64c8652..7fcdebb 100644
--- a/tests/unit/security/pib/pib-data-fixture.hpp
+++ b/tests/unit/security/pib/pib-data-fixture.hpp
@@ -25,20 +25,19 @@
#include "ndn-cxx/security/certificate.hpp"
#include "ndn-cxx/security/pib/pib-impl.hpp"
-namespace ndn {
-namespace security {
-namespace pib {
-namespace tests {
+namespace ndn::tests {
+
+using ndn::security::Certificate;
class PibDataFixture
{
public:
PibDataFixture();
- [[nodiscard]] static shared_ptr<PibImpl>
+ [[nodiscard]] static shared_ptr<security::pib::PibImpl>
makePibWithIdentity(const Name& idName);
- [[nodiscard]] static shared_ptr<PibImpl>
+ [[nodiscard]] static shared_ptr<security::pib::PibImpl>
makePibWithKey(const Name& keyName, span<const uint8_t> key);
public:
@@ -65,9 +64,6 @@
Buffer id2Key2;
};
-} // namespace tests
-} // namespace pib
-} // namespace security
-} // namespace ndn
+} // namespace ndn::tests
#endif // NDN_CXX_TESTS_UNIT_SECURITY_PIB_PIB_DATA_FIXTURE_HPP
diff --git a/tests/unit/security/pib/pib-impl.t.cpp b/tests/unit/security/pib/pib-impl.t.cpp
index d88bad6..b26109d 100644
--- a/tests/unit/security/pib/pib-impl.t.cpp
+++ b/tests/unit/security/pib/pib-impl.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).
*
@@ -29,17 +29,13 @@
#include <boost/filesystem.hpp>
#include <boost/mpl/vector.hpp>
-namespace ndn {
-namespace security {
-namespace pib {
-namespace tests {
+namespace ndn::tests {
+
+using namespace ndn::security::pib;
BOOST_AUTO_TEST_SUITE(Security)
-BOOST_AUTO_TEST_SUITE(Pib)
BOOST_AUTO_TEST_SUITE(TestPibImpl)
-using pib::Pib;
-
class PibMemoryFixture : public PibDataFixture
{
public:
@@ -336,10 +332,6 @@
}
BOOST_AUTO_TEST_SUITE_END() // TestPibImpl
-BOOST_AUTO_TEST_SUITE_END() // Pib
BOOST_AUTO_TEST_SUITE_END() // Security
-} // namespace tests
-} // namespace pib
-} // namespace security
-} // namespace ndn
+} // namespace ndn::tests
diff --git a/tests/unit/security/pib/pib.t.cpp b/tests/unit/security/pib/pib.t.cpp
index 8d668e5..3a665c3 100644
--- a/tests/unit/security/pib/pib.t.cpp
+++ b/tests/unit/security/pib/pib.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).
*
@@ -25,17 +25,13 @@
#include "tests/boost-test.hpp"
#include "tests/unit/security/pib/pib-data-fixture.hpp"
-namespace ndn {
-namespace security {
-namespace pib {
-namespace tests {
+namespace ndn::tests {
+
+using namespace ndn::security::pib;
BOOST_AUTO_TEST_SUITE(Security)
-BOOST_AUTO_TEST_SUITE(Pib)
BOOST_FIXTURE_TEST_SUITE(TestPib, PibDataFixture)
-using pib::Pib;
-
BOOST_AUTO_TEST_CASE(TpmLocator)
{
Pib pib("pib-memory:", make_shared<PibMemory>());
@@ -116,10 +112,6 @@
}
BOOST_AUTO_TEST_SUITE_END() // TestPib
-BOOST_AUTO_TEST_SUITE_END() // Pib
BOOST_AUTO_TEST_SUITE_END() // Security
-} // namespace tests
-} // namespace pib
-} // namespace security
-} // namespace ndn
+} // namespace ndn::tests