Use nested namespace
Nested namespace is introduced in C++ 17. This saves nearly 50 lines.
This change also puts tests into a nested namespace, which saves
unnecessary using directives.
Signed-off-by: Nan Zhou <nanzhoumails@gmail.com>
Change-Id: I7c3e38588fd5c2cbd83ac13ee24327318e8c06a4
diff --git a/test/ca_certs_manager_test.cpp b/test/ca_certs_manager_test.cpp
index 17c8589..5bdad56 100644
--- a/test/ca_certs_manager_test.cpp
+++ b/test/ca_certs_manager_test.cpp
@@ -10,9 +10,12 @@
#include <gtest/gtest.h>
+namespace ca::cert
+{
+namespace
+{
using InvalidArgument =
sdbusplus::xyz::openbmc_project::Common::Error::InvalidArgument;
-using namespace ca::cert;
class MockCACertMgr : public CACertMgr
{
@@ -123,3 +126,5 @@
manager.erase(std::stoi(id));
EXPECT_TRUE(manager.getNumOfEntries() == 0);
}
+} // namespace
+} // namespace ca::cert
diff --git a/test/certs_manager_test.cpp b/test/certs_manager_test.cpp
index 38c563a..1131df1 100644
--- a/test/certs_manager_test.cpp
+++ b/test/certs_manager_test.cpp
@@ -20,12 +20,16 @@
#include <xyz/openbmc_project/Common/error.hpp>
#include <gtest/gtest.h>
+
+namespace phosphor::certs
+{
+namespace
+{
namespace fs = std::filesystem;
using InternalFailure =
sdbusplus::xyz::openbmc_project::Common::Error::InternalFailure;
using InvalidCertificate =
sdbusplus::xyz::openbmc_project::Certs::Error::InvalidCertificate;
-using namespace phosphor::certs;
/**
* Class to generate certificate file and test verification of certificate file
@@ -1380,3 +1384,5 @@
std::move(installPath));
EXPECT_TRUE(fs::exists(rsaPrivateKeyFilePath));
}
+} // namespace
+} // namespace phosphor::certs