redfish-core tests: use matcher correctly

This commit corrects the usage of ASSERT, EXPECT, and all the matchers.
It also fixes cases where a cleaner matcher can be used.

This commit increases readability (with correct and cleaner matcher) and
corrects bugs (access iterator before checking validity).

Typical incorrect usage is that when a function returns a boolean value
to indicated whether the function succeeds or not, unless the function
has clear behavior when it fails, we shouldn't continue the test that
inspects the output parameters. A typical test codes look like this,

```
ASSERT_TRUE(fooBar(output));
EXPECT_EQ(output, 123);
```

Reference:
https://testing.googleblog.com/2008/07/tott-expect-vs-assert.html
https://github.com/google/googletest/blob/main/docs/reference/matchers.md

Tested: unit test passed.

Signed-off-by: Nan Zhou <nanzhoumails@gmail.com>
Change-Id: Ia2cf9922bd4cb2fe8b4b3912e9153e9ae4eab134
diff --git a/redfish-core/ut/privileges_test.cpp b/redfish-core/ut/privileges_test.cpp
index 3813b54..c5a7a87 100644
--- a/redfish-core/ut/privileges_test.cpp
+++ b/redfish-core/ut/privileges_test.cpp
@@ -11,12 +11,15 @@
 namespace
 {
 
+using ::testing::IsEmpty;
+using ::testing::UnorderedElementsAre;
+
 TEST(PrivilegeTest, PrivilegeConstructor)
 {
     Privileges privileges{"Login", "ConfigureManager"};
 
     EXPECT_THAT(privileges.getActivePrivilegeNames(PrivilegeType::BASE),
-                ::testing::UnorderedElementsAre("Login", "ConfigureManager"));
+                UnorderedElementsAre("Login", "ConfigureManager"));
 }
 
 TEST(PrivilegeTest, PrivilegeCheckForNoPrivilegesRequired)
@@ -96,10 +99,10 @@
     Privileges privileges;
 
     EXPECT_THAT(privileges.getActivePrivilegeNames(PrivilegeType::BASE),
-                ::testing::IsEmpty());
+                IsEmpty());
 
     EXPECT_THAT(privileges.getActivePrivilegeNames(PrivilegeType::OEM),
-                ::testing::IsEmpty());
+                IsEmpty());
 }
 
 TEST(PrivilegeTest, GetActivePrivilegeNames)
@@ -107,7 +110,7 @@
     Privileges privileges;
 
     EXPECT_THAT(privileges.getActivePrivilegeNames(PrivilegeType::BASE),
-                ::testing::IsEmpty());
+                IsEmpty());
 
     std::array<const char*, 5> expectedPrivileges{
         "Login", "ConfigureManager", "ConfigureUsers", "ConfigureComponents",
@@ -118,11 +121,11 @@
         EXPECT_TRUE(privileges.setSinglePrivilege(privilege));
     }
 
-    EXPECT_THAT(privileges.getActivePrivilegeNames(PrivilegeType::BASE),
-                ::testing::UnorderedElementsAre(
-                    expectedPrivileges[0], expectedPrivileges[1],
-                    expectedPrivileges[2], expectedPrivileges[3],
-                    expectedPrivileges[4]));
+    EXPECT_THAT(
+        privileges.getActivePrivilegeNames(PrivilegeType::BASE),
+        UnorderedElementsAre(expectedPrivileges[0], expectedPrivileges[1],
+                             expectedPrivileges[2], expectedPrivileges[3],
+                             expectedPrivileges[4]));
 }
 } // namespace
 } // namespace redfish
\ No newline at end of file