user exist: simplify expression, add unit test

Simplified two boolean expression and added unit tests. The unit test
container has the root user by default and can be leveraged in the unit
test.

Tested: unit test passed.

Signed-off-by: Nan Zhou <nanzhoumails@gmail.com>
Change-Id: Ia335ad9e14e5cdeca5c260ef67f308f7197be349
diff --git a/test/user_mgr_test.cpp b/test/user_mgr_test.cpp
index f16a9d6..15a56fc 100644
--- a/test/user_mgr_test.cpp
+++ b/test/user_mgr_test.cpp
@@ -310,5 +310,26 @@
     EXPECT_EQ(setPamModuleArgValue("pam_tally2.so", "minlen", "16"), -1);
 }
 
+TEST_F(UserMgrInTest, IsUserExistEmptyInputThrowsError)
+{
+    EXPECT_THROW(
+        isUserExist(""),
+        sdbusplus::xyz::openbmc_project::Common::Error::InvalidArgument);
+}
+
+TEST_F(UserMgrInTest, ThrowForUserDoesNotExistThrowsError)
+{
+    EXPECT_THROW(throwForUserDoesNotExist("whatever"),
+                 sdbusplus::xyz::openbmc_project::User::Common::Error::
+                     UserNameDoesNotExist);
+}
+
+TEST_F(UserMgrInTest, ThrowForUserExistsThrowsError)
+{
+    EXPECT_THROW(
+        throwForUserExists("root"),
+        sdbusplus::xyz::openbmc_project::User::Common::Error::UserNameExists);
+}
+
 } // namespace user
 } // namespace phosphor