Index: base/ios/device_util_unittest.mm |
diff --git a/base/ios/device_util_unittest.mm b/base/ios/device_util_unittest.mm |
index a0c9ec49fc221ae6bafbf585e53c2aa4e2080714..688acc10eabcc66734449ebbd4a8e5b1ab0edffc 100644 |
--- a/base/ios/device_util_unittest.mm |
+++ b/base/ios/device_util_unittest.mm |
@@ -99,6 +99,33 @@ TEST_F(DeviceUtilTest, CheckMigrationFromZero) { |
CleanNSUserDefaultsForDeviceId(); |
} |
+TEST_F(DeviceUtilTest, GetSaltedStringEquals) { |
+ std::string string1("The quick brown fox jumps over the lazy dog"); |
+ std::string string2("The quick brown fox jumps over the lazy dog"); |
+ std::string salt("salt"); |
+ // Same string and same salt should result in the same salted string. |
+ EXPECT_EQ(ios::device_util::GetSaltedString(string1, salt), |
+ ios::device_util::GetSaltedString(string2, salt)); |
+} |
+ |
+TEST_F(DeviceUtilTest, GetSaltedStringNotEquals) { |
+ std::string string1("The quick brown fox jumps over the lazy dog"); |
+ std::string string2("The lazy brown fox jumps over the quick dog"); |
+ std::string salt("salt"); |
+ // Different string and same salt should result in different salted strings. |
+ EXPECT_NE(ios::device_util::GetSaltedString(string1, salt), |
+ ios::device_util::GetSaltedString(string2, salt)); |
+} |
+ |
+TEST_F(DeviceUtilTest, GetSaltedStringDifferentSalt) { |
+ std::string string1("The quick brown fox jumps over the lazy dog"); |
+ std::string salt1("salt"); |
+ std::string salt2("pepper"); |
+ // Same string with different salt should result in different salted strings. |
+ EXPECT_NE(ios::device_util::GetSaltedString(string1, salt1), |
+ ios::device_util::GetSaltedString(string1, salt2)); |
+} |
+ |
TEST_F(DeviceUtilTest, CheckDeviceMigration) { |
CleanNSUserDefaultsForDeviceId(); |