Chromium Code Reviews| Index: chrome/browser/autofill/password_generator_unittest.cc |
| diff --git a/chrome/browser/autofill/password_generator_unittest.cc b/chrome/browser/autofill/password_generator_unittest.cc |
| index 4efbc8bc8636481d77e16ed7fb0fd7e7af6d55d1..4b72c80cffc5be64ff579dfcc025ccb10f0f61dc 100644 |
| --- a/chrome/browser/autofill/password_generator_unittest.cc |
| +++ b/chrome/browser/autofill/password_generator_unittest.cc |
| @@ -10,9 +10,42 @@ |
| namespace autofill { |
| -TEST(PasswordGeneratorTest, PasswordGeneratorSimpleTest) { |
| - // Not much to test, just make sure that the characters in a generated |
| - // password are reasonable. |
| +TEST(PasswordGeneratorTest, TestPasswordLength) { |
|
Ilya Sherman
2012/06/01 01:09:55
nit: "TestPasswordLength" -> "PasswordLength" (and
zysxqn
2012/06/01 19:01:32
Done.
|
| + PasswordGenerator pg1(10); |
| + std::string password = pg1.Generate(); |
| + EXPECT_EQ(password.size(), 10u); |
|
Ilya Sherman
2012/06/01 01:09:55
nit: Please add a blank line after this line.
zysxqn
2012/06/01 19:01:32
Done.
|
| + PasswordGenerator pg2(-1); |
| + password = pg2.Generate(); |
| + EXPECT_EQ(password.size(), kDefaultPasswordLength); |
|
Ilya Sherman
2012/06/01 01:09:55
nit: Please add a blank line after this line.
zysxqn
2012/06/01 19:01:32
Done.
|
| + PasswordGenerator pg3(100); |
| + password = pg3.Generate(); |
| + EXPECT_EQ(password.size(), kDefaultPasswordLength); |
| +} |
| + |
| +TEST(PasswordGeneratorTest, TestPasswordPattern) { |
| + PasswordGenerator pg; |
| + std::string password = pg.Generate(); |
| + int num_upper_case_letters = 0; |
| + int num_lower_case_letters = 0; |
| + int num_digits = 0; |
| + int num_other_symbols = 0; |
| + for (size_t i = 0; i < password.size(); i++) { |
| + if (isupper(password[i])) |
| + ++num_upper_case_letters; |
| + else if (islower(password[i])) |
| + ++num_lower_case_letters; |
| + else if (isdigit(password[i])) |
| + ++num_digits; |
| + else |
| + ++num_other_symbols; |
| + } |
| + EXPECT_GT(num_upper_case_letters, 0); |
| + EXPECT_GT(num_lower_case_letters, 0); |
| + EXPECT_GT(num_digits, 0); |
| + EXPECT_GT(num_other_symbols, 0); |
| +} |
| + |
| +TEST(PasswordGeneratorTest, TestPrintable) { |
| PasswordGenerator pg; |
| std::string password = pg.Generate(); |
| for (size_t i = 0; i < password.size(); i++) { |