forked from ChicoState/UnitTestPractice
-
Notifications
You must be signed in to change notification settings - Fork 0
/
PasswordTest.cpp
70 lines (58 loc) · 1.93 KB
/
PasswordTest.cpp
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
#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 for count_leading_characters
TEST(PasswordTest, single_letter_password) {
Password my_password;
int actual = my_password.count_leading_characters("Z");
ASSERT_EQ(1, actual);
}
TEST(PasswordTest, multiple_leading_characters) {
Password my_password;
int actual = my_password.count_leading_characters("AAAxyz");
ASSERT_EQ(3, actual);
}
TEST(PasswordTest, no_repeating_leading_characters) {
Password my_password;
int actual = my_password.count_leading_characters("ABCD");
ASSERT_EQ(1, actual);
}
TEST(PasswordTest, empty_string) {
Password my_password;
int actual = my_password.count_leading_characters("");
ASSERT_EQ(0, actual);
}
TEST(PasswordTest, all_same_characters) {
Password my_password;
int actual = my_password.count_leading_characters("BBBBB");
ASSERT_EQ(5, actual);
}
// Test for has_mixed_case
TEST(PasswordTest, mixed_case_password) {
Password my_password;
ASSERT_TRUE(my_password.has_mixed_case("Password123"));
ASSERT_TRUE(my_password.has_mixed_case("helloWORLD"));
}
TEST(PasswordTest, all_lowercase_password) {
Password my_password;
ASSERT_FALSE(my_password.has_mixed_case("alllowercase"));
}
TEST(PasswordTest, all_uppercase_password) {
Password my_password;
ASSERT_FALSE(my_password.has_mixed_case("ALLUPPERCASE"));
}
TEST(PasswordTest, no_letters) {
Password my_password;
ASSERT_FALSE(my_password.has_mixed_case("123456"));
}
TEST(PasswordTest, mixed_case_with_symbols) {
Password my_password;
ASSERT_TRUE(my_password.has_mixed_case("Mix3d_C@s3"));
}