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
130 lines (107 loc) · 3.09 KB
/
PasswordTest.cpp
File metadata and controls
130 lines (107 loc) · 3.09 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
/**
* 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)
};
<<<<<<< HEAD
=======
// has_mixed_case tests
>>>>>>> 07d43ebb58811f385f85b7d14c4186e8cc77607d
TEST(PasswordTest, mixed_case_password)
{
Password my_password;
bool mixed = my_password.has_mixed_case("Hello");
ASSERT_EQ(true, mixed);
}
TEST(PasswordTest, mixed_case2_password)
{
Password my_password;
bool mixed = my_password.has_mixed_case("HeLlO");
ASSERT_EQ(true, mixed);
}
TEST(PasswordTest, mixed_case3_password)
{
Password my_password;
bool mixed = my_password.has_mixed_case("This is a mixed case.");
ASSERT_EQ(true, mixed);
}
TEST(PasswordTest, not_mixed_case_password)
{
Password my_password;
bool mixed = my_password.has_mixed_case("hello");
ASSERT_EQ(false, mixed);
}
TEST(PasswordTest, not_mixed_case2_password)
{
Password my_password;
bool mixed = my_password.has_mixed_case("not mixed case");
ASSERT_EQ(false, mixed);
}
TEST(PasswordTest, not_mixed_case3_password)
{
Password my_password;
bool mixed = my_password.has_mixed_case("");
ASSERT_EQ(false, mixed);
}
TEST(PasswordTest, not_mixed_case4_password)
{
Password my_password;
bool mixed = my_password.has_mixed_case("./.' ,.");
ASSERT_EQ(false, mixed);
}
TEST(PasswordTest, single_letter_password)
{
Password my_password;
int actual = my_password.count_leading_characters("Z");
ASSERT_EQ(1, actual); // assert that actual should be equal to 1
}
TEST(PasswordTest, three_letter_password)
{
Password my_password;
int actual = my_password.count_leading_characters("aaab");
ASSERT_EQ(3, actual); // assert that actual should be equal to 3
}
TEST(PasswordTest, start_lower_letter_password)
{
Password my_password;
int actual = my_password.count_leading_characters("aAb");
ASSERT_EQ(1, actual); // assert that actual should be equal to 1
}
TEST(PasswordTest, all_lower_letter_password)
{
Password my_password;
int actual = my_password.count_leading_characters("aaa");
ASSERT_EQ(3, actual); // assert that actual should be equal to 3
}
TEST(PasswordTest, start_capital_letter_password)
{
Password my_password;
int actual = my_password.count_leading_characters("Aab");
ASSERT_EQ(1, actual); // assert that actual should be equal to 1
}
TEST(PasswordTest, nothing_letter_password)
{
Password my_password;
int actual = my_password.count_leading_characters("");
ASSERT_EQ(0, actual); // assert that actual should be equal to 0
}
TEST(PasswordTest, empty_char_letter_password)
{
Password my_password;
int actual = my_password.count_leading_characters("aa a ba");
ASSERT_EQ(2, actual); // assert that actual should be equal to 2
}
TEST(PasswordTest, all_upper_letter_password)
{
Password my_password;
int actual = my_password.count_leading_characters("AAA");
ASSERT_EQ(3, actual); // assert that actual should be equal to 3
}