rememberOldPasswordTimes: add unit test

This commit adds several test cases for |rememberOldPasswordTimes|.

Tested: unit test passed.

Overall coverage rate:
  lines......: 79.2% (1809 of 2283 lines)
  functions..: 92.8% (361 of 389 functions)
  branches...: 32.4% (2852 of 8814 branches)

Signed-off-by: Nan Zhou <nanzhoumails@gmail.com>
Change-Id: Iea033026b79a81d67dfb3d513eb951b0b6cb21b6
diff --git a/test/user_mgr_test.cpp b/test/user_mgr_test.cpp
index d10921a..b8d61e3 100644
--- a/test/user_mgr_test.cpp
+++ b/test/user_mgr_test.cpp
@@ -590,5 +590,34 @@
     EXPECT_EQ(AccountPolicyIface::minPasswordLength(), 8);
 }
 
+TEST_F(UserMgrInTest, RememberOldPasswordTimesReturnsIfValueIsTheSame)
+{
+    initializeAccountPolicy();
+    EXPECT_EQ(AccountPolicyIface::rememberOldPasswordTimes(), 0);
+    UserMgr::rememberOldPasswordTimes(8);
+    EXPECT_EQ(AccountPolicyIface::rememberOldPasswordTimes(), 8);
+    UserMgr::rememberOldPasswordTimes(8);
+    EXPECT_EQ(AccountPolicyIface::rememberOldPasswordTimes(), 8);
+}
+
+TEST_F(UserMgrInTest, RememberOldPasswordTimesOnSuccess)
+{
+    initializeAccountPolicy();
+    EXPECT_EQ(AccountPolicyIface::rememberOldPasswordTimes(), 0);
+    UserMgr::rememberOldPasswordTimes(16);
+    EXPECT_EQ(AccountPolicyIface::rememberOldPasswordTimes(), 16);
+}
+
+TEST_F(UserMgrInTest, RememberOldPasswordTimesOnFailure)
+{
+    EXPECT_NO_THROW(dumpStringToFile("whatever", tempPamConfigFile));
+    initializeAccountPolicy();
+    EXPECT_EQ(AccountPolicyIface::rememberOldPasswordTimes(), 0);
+    EXPECT_THROW(
+        UserMgr::rememberOldPasswordTimes(16),
+        sdbusplus::xyz::openbmc_project::Common::Error::InternalFailure);
+    EXPECT_EQ(AccountPolicyIface::rememberOldPasswordTimes(), 0);
+}
+
 } // namespace user
 } // namespace phosphor