forked from ChicoState/UnitTestPractice
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPasswordTest.cpp
More file actions
129 lines (103 loc) · 2.5 KB
/
PasswordTest.cpp
File metadata and controls
129 lines (103 loc) · 2.5 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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
/**
* 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, mixed_case_password)
{
Password my_password;
int actual = my_password.count_leading_characters("ZZz");
ASSERT_EQ(2, actual);
}
TEST(PasswordTest, empty_password)
{
Password my_password;
int actual = my_password.count_leading_characters("");
ASSERT_EQ(0, actual);
}
TEST(PasswordTest, long_password)
{
Password my_password;
int actual = my_password.count_leading_characters("zzzzzzzzzzzzzzz");
ASSERT_EQ(15, actual);
}
TEST(PasswordTest, has_mixed_case)
{
Password my_password;
int actual = my_password.has_mixed_case("ZzZ");
ASSERT_TRUE(actual);
}
TEST(PasswordTest, all_uppercase)
{
Password my_password;
int actual = my_password.has_mixed_case("ZZZ");
ASSERT_FALSE(actual);
}
TEST(PasswordTest, all_lowercase)
{
Password my_password;
int actual = my_password.has_mixed_case("zzz");
ASSERT_FALSE(actual);
}
TEST(PasswordTest, mixed_not_matching)
{
Password my_password;
int actual = my_password.has_mixed_case("ZaB");
ASSERT_TRUE(actual);
}
TEST(PasswordTest, mixed_empty)
{
Password my_password;
int actual = my_password.has_mixed_case("");
ASSERT_FALSE(actual);
}
TEST(PasswordTest, starting_lower)
{
Password my_password;
int actual = my_password.has_mixed_case("zZZ");
ASSERT_TRUE(actual);
}
TEST(PasswordTest, number_password_lower)
{
Password my_password;
int actual = my_password.has_mixed_case("q123");
ASSERT_FALSE(actual);
}
TEST(PasswordTest, number_password_upper)
{
Password my_password;
int actual = my_password.has_mixed_case("Q123");
ASSERT_FALSE(actual);
}
TEST(PasswordTest, unique_char_repeats)
{
Password my_password;
int actual = my_password.unique_characters("abcabc");
ASSERT_EQ(3,actual);
}
TEST(PasswordTest, unique_char_no_repeats)
{
Password my_password;
int actual = my_password.unique_characters("abcdefg");
ASSERT_EQ(7,actual);
}
TEST(PasswordTest, unqiue_char_numbers)
{
Password my_password;
int actual = my_password.unique_characters("012345678910");
ASSERT_EQ(10,actual);
}