openbmc_dbus_rest_test: refactor tests

Thhis commit added namespace to unit tests and using declarations,
which is a common practise to avoid duplicate namespaces in unit tests.

It can be shown that after this change, many namespace scoping codes
disappear.

Tested:
1. Unit test passed.

Signed-off-by: Nan Zhou <nanzhoumails@gmail.com>
Change-Id: I02e221f83c1e330fb57122c8daccbe180ec37a14
diff --git a/include/ut/openbmc_dbus_rest_test.cpp b/include/ut/openbmc_dbus_rest_test.cpp
index 554ab74..ea99a1b 100644
--- a/include/ut/openbmc_dbus_rest_test.cpp
+++ b/include/ut/openbmc_dbus_rest_test.cpp
@@ -3,83 +3,69 @@
 #include "gmock/gmock.h"
 #include "gtest/gtest.h"
 
+namespace crow::openbmc_mapper
+{
+namespace
+{
+
+using ::testing::ElementsAre;
 // Also see redfish-core/ut/configfile_test.cpp
 TEST(OpenbmcDbusRestTest, ValidFilenameGood)
 {
-    EXPECT_TRUE(crow::openbmc_mapper::validateFilename("GoodConfigFile"));
-    EXPECT_TRUE(crow::openbmc_mapper::validateFilename("_Underlines_"));
-    EXPECT_TRUE(crow::openbmc_mapper::validateFilename("8675309"));
-    EXPECT_TRUE(crow::openbmc_mapper::validateFilename("-Dashes-"));
-    EXPECT_TRUE(crow::openbmc_mapper::validateFilename("With Spaces"));
-    EXPECT_TRUE(crow::openbmc_mapper::validateFilename("One.Dot"));
-    EXPECT_TRUE(crow::openbmc_mapper::validateFilename("trailingdot."));
-    EXPECT_TRUE(crow::openbmc_mapper::validateFilename("-_ o _-"));
-    EXPECT_TRUE(crow::openbmc_mapper::validateFilename(" "));
-    EXPECT_TRUE(crow::openbmc_mapper::validateFilename(" ."));
+    EXPECT_TRUE(validateFilename("GoodConfigFile"));
+    EXPECT_TRUE(validateFilename("_Underlines_"));
+    EXPECT_TRUE(validateFilename("8675309"));
+    EXPECT_TRUE(validateFilename("-Dashes-"));
+    EXPECT_TRUE(validateFilename("With Spaces"));
+    EXPECT_TRUE(validateFilename("One.Dot"));
+    EXPECT_TRUE(validateFilename("trailingdot."));
+    EXPECT_TRUE(validateFilename("-_ o _-"));
+    EXPECT_TRUE(validateFilename(" "));
+    EXPECT_TRUE(validateFilename(" ."));
 }
 
 // There is no length test yet because validateFilename() does not care yet
 TEST(OpenbmcDbusRestTest, ValidFilenameBad)
 {
-    EXPECT_FALSE(crow::openbmc_mapper::validateFilename(""));
-    EXPECT_FALSE(crow::openbmc_mapper::validateFilename("Bad@file"));
-    EXPECT_FALSE(
-        crow::openbmc_mapper::validateFilename("/../../../../../etc/badpath"));
-    EXPECT_FALSE(crow::openbmc_mapper::validateFilename("/../../etc/badpath"));
-    EXPECT_FALSE(crow::openbmc_mapper::validateFilename("/mydir/configFile"));
-    EXPECT_FALSE(crow::openbmc_mapper::validateFilename("/"));
-    EXPECT_FALSE(crow::openbmc_mapper::validateFilename(".leadingdot"));
-    EXPECT_FALSE(crow::openbmc_mapper::validateFilename("Two..Dots"));
-    EXPECT_FALSE(
-        crow::openbmc_mapper::validateFilename("../../../../../../etc/shadow"));
-    EXPECT_FALSE(crow::openbmc_mapper::validateFilename("."));
+    EXPECT_FALSE(validateFilename(""));
+    EXPECT_FALSE(validateFilename("Bad@file"));
+    EXPECT_FALSE(validateFilename("/../../../../../etc/badpath"));
+    EXPECT_FALSE(validateFilename("/../../etc/badpath"));
+    EXPECT_FALSE(validateFilename("/mydir/configFile"));
+    EXPECT_FALSE(validateFilename("/"));
+    EXPECT_FALSE(validateFilename(".leadingdot"));
+    EXPECT_FALSE(validateFilename("Two..Dots"));
+    EXPECT_FALSE(validateFilename("../../../../../../etc/shadow"));
+    EXPECT_FALSE(validateFilename("."));
 }
 
 TEST(OpenBmcDbusTest, TestArgSplit)
 {
     // test the basic types
-    EXPECT_THAT(crow::openbmc_mapper::dbusArgSplit("x"),
-                ::testing::ElementsAre("x"));
-    EXPECT_THAT(crow::openbmc_mapper::dbusArgSplit("y"),
-                ::testing::ElementsAre("y"));
-    EXPECT_THAT(crow::openbmc_mapper::dbusArgSplit("b"),
-                ::testing::ElementsAre("b"));
-    EXPECT_THAT(crow::openbmc_mapper::dbusArgSplit("n"),
-                ::testing::ElementsAre("n"));
-    EXPECT_THAT(crow::openbmc_mapper::dbusArgSplit("q"),
-                ::testing::ElementsAre("q"));
-    EXPECT_THAT(crow::openbmc_mapper::dbusArgSplit("i"),
-                ::testing::ElementsAre("i"));
-    EXPECT_THAT(crow::openbmc_mapper::dbusArgSplit("u"),
-                ::testing::ElementsAre("u"));
-    EXPECT_THAT(crow::openbmc_mapper::dbusArgSplit("x"),
-                ::testing::ElementsAre("x"));
-    EXPECT_THAT(crow::openbmc_mapper::dbusArgSplit("t"),
-                ::testing::ElementsAre("t"));
-    EXPECT_THAT(crow::openbmc_mapper::dbusArgSplit("d"),
-                ::testing::ElementsAre("d"));
-    EXPECT_THAT(crow::openbmc_mapper::dbusArgSplit("h"),
-                ::testing::ElementsAre("h"));
+    EXPECT_THAT(dbusArgSplit("x"), ElementsAre("x"));
+    EXPECT_THAT(dbusArgSplit("y"), ElementsAre("y"));
+    EXPECT_THAT(dbusArgSplit("b"), ElementsAre("b"));
+    EXPECT_THAT(dbusArgSplit("n"), ElementsAre("n"));
+    EXPECT_THAT(dbusArgSplit("q"), ElementsAre("q"));
+    EXPECT_THAT(dbusArgSplit("i"), ElementsAre("i"));
+    EXPECT_THAT(dbusArgSplit("u"), ElementsAre("u"));
+    EXPECT_THAT(dbusArgSplit("x"), ElementsAre("x"));
+    EXPECT_THAT(dbusArgSplit("t"), ElementsAre("t"));
+    EXPECT_THAT(dbusArgSplit("d"), ElementsAre("d"));
+    EXPECT_THAT(dbusArgSplit("h"), ElementsAre("h"));
     // test arrays
-    EXPECT_THAT(crow::openbmc_mapper::dbusArgSplit("ai"),
-                ::testing::ElementsAre("ai"));
-    EXPECT_THAT(crow::openbmc_mapper::dbusArgSplit("ax"),
-                ::testing::ElementsAre("ax"));
+    EXPECT_THAT(dbusArgSplit("ai"), ElementsAre("ai"));
+    EXPECT_THAT(dbusArgSplit("ax"), ElementsAre("ax"));
     // test tuples
-    EXPECT_THAT(crow::openbmc_mapper::dbusArgSplit("(sss)"),
-                ::testing::ElementsAre("(sss)"));
-    EXPECT_THAT(crow::openbmc_mapper::dbusArgSplit("(sss)b"),
-                ::testing::ElementsAre("(sss)", "b"));
-    EXPECT_THAT(crow::openbmc_mapper::dbusArgSplit("b(sss)"),
-                ::testing::ElementsAre("b", "(sss)"));
+    EXPECT_THAT(dbusArgSplit("(sss)"), ElementsAre("(sss)"));
+    EXPECT_THAT(dbusArgSplit("(sss)b"), ElementsAre("(sss)", "b"));
+    EXPECT_THAT(dbusArgSplit("b(sss)"), ElementsAre("b", "(sss)"));
 
     // Test nested types
-    EXPECT_THAT(crow::openbmc_mapper::dbusArgSplit("a{si}b"),
-                ::testing::ElementsAre("a{si}", "b"));
-    EXPECT_THAT(crow::openbmc_mapper::dbusArgSplit("a(sss)b"),
-                ::testing::ElementsAre("a(sss)", "b"));
-    EXPECT_THAT(crow::openbmc_mapper::dbusArgSplit("aa{si}b"),
-                ::testing::ElementsAre("aa{si}", "b"));
-    EXPECT_THAT(crow::openbmc_mapper::dbusArgSplit("i{si}b"),
-                ::testing::ElementsAre("i", "{si}", "b"));
+    EXPECT_THAT(dbusArgSplit("a{si}b"), ElementsAre("a{si}", "b"));
+    EXPECT_THAT(dbusArgSplit("a(sss)b"), ElementsAre("a(sss)", "b"));
+    EXPECT_THAT(dbusArgSplit("aa{si}b"), ElementsAre("aa{si}", "b"));
+    EXPECT_THAT(dbusArgSplit("i{si}b"), ElementsAre("i", "{si}", "b"));
 }
+} // namespace
+} // namespace crow::openbmc_mapper