Repository navigation
Expand file tree
/
Copy pathPasswordTest.cpp
More file actions
75 lines (58 loc) · 1.74 KB
/
Copy pathPasswordTest.cpp
File metadata and controls
75 lines (58 loc) · 1.74 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
/**
* Unit Tests for Password class
**/
#include <gtest/gtest.h>
#include "Password.h"
class PasswordTest : public ::testing::Test
{
protected:
PasswordTest(){} //constructor runs before each test
virtual ~PasswordTest(){} //destructor cleans up after tests
virtual void SetUp(){} //sets up before each test (after constructor)
virtual void TearDown(){} //clean up after each test, (before destructor)
};
TEST(PasswordTest, single_letter_password)
{
Password my_password;
int actual = my_password.count_leading_characters("Z");
ASSERT_EQ(1, actual);
}
TEST(PasswordTest, counts_only_the_leading_run)
{
Password my_password;
EXPECT_EQ(3, my_password.count_leading_characters("aaab"));
}
TEST(PasswordTest, leading_count_is_case_sensitive)
{
Password my_password;
EXPECT_EQ(1, my_password.count_leading_characters("aAaa"));
}
TEST(PasswordTest, empty_password_has_no_leading_characters)
{
Password my_password;
EXPECT_EQ(0, my_password.count_leading_characters(""));
}
TEST(PasswordTest, mixed_case_requires_an_uppercase_and_a_lowercase_letter)
{
Password my_password;
EXPECT_TRUE(my_password.has_mixed_case("Password"));
}
TEST(PasswordTest, mixed_case_can_have_letters_in_any_order)
{
Password my_password;
EXPECT_TRUE(my_password.has_mixed_case("pASSWORD"));
}
TEST(PasswordTest, digits_and_symbols_do_not_count_as_case)
{
Password my_password;
EXPECT_FALSE(my_password.has_mixed_case("1234!@#$"));
EXPECT_FALSE(my_password.has_mixed_case("UPPER123!"));
EXPECT_FALSE(my_password.has_mixed_case("lower123!"));
}
TEST(PasswordTest, a_single_letter_cannot_have_mixed_case)
{
Password my_password;
EXPECT_FALSE(my_password.has_mixed_case("A"));
EXPECT_FALSE(my_password.has_mixed_case("z"));
EXPECT_FALSE(my_password.has_mixed_case(""));
}