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
100 lines (85 loc) · 2.13 KB
/
PasswordTest.cpp
File metadata and controls
100 lines (85 loc) · 2.13 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
/**
* Unit Tests for Password class
**/
#include <gtest/gtest.h>
#include "Password.h"
class PasswordTest : public ::testing::Test
{
protected:
PasswordTest(){}
virtual ~PasswordTest(){}
virtual void SetUp(){}
virtual void TearDown(){}
};
TEST(PasswordTest, single_letter_password)
{
Password my_password;
int actual = my_password.count_leading_characters("Z");
ASSERT_EQ(1, actual);
}
TEST(PasswordTest, empty_string_has_zero_leading_characters)
{
Password my_password;
int actual = my_password.count_leading_characters("");
ASSERT_EQ(0, actual);
}
TEST(PasswordTest, all_same_characters_are_counted)
{
Password my_password;
int actual = my_password.count_leading_characters("AAAA");
ASSERT_EQ(4, actual);
}
TEST(PasswordTest, stops_counting_when_character_changes)
{
Password my_password;
int actual = my_password.count_leading_characters("AAABCD");
ASSERT_EQ(3, actual);
}
TEST(PasswordTest, no_repeating_leading_characters_returns_one)
{
Password my_password;
int actual = my_password.count_leading_characters("ABCDE");
ASSERT_EQ(1, actual);
}
TEST(PasswordTest, case_sensitive_leading_character_count)
{
Password my_password;
int actual = my_password.count_leading_characters("AaAAA");
ASSERT_EQ(1, actual);
}
TEST(PasswordTest, counts_leading_special_characters)
{
Password my_password;
int actual = my_password.count_leading_characters("!!!abc");
ASSERT_EQ(3, actual);
}
TEST(PasswordTest, all_lowercase_returns_false)
{
Password my_password;
bool actual = my_password.has_mixed_case("abc");
ASSERT_FALSE(actual);
}
TEST(PasswordTest, all_uppercase_returns_false)
{
Password my_password;
bool actual = my_password.has_mixed_case("ABC");
ASSERT_FALSE(actual);
}
TEST(PasswordTest, empty_string_is_not_mixed_case)
{
Password my_password;
bool actual = my_password.has_mixed_case("");
ASSERT_FALSE(actual);
}
TEST(PasswordTest, numbers_only_are_not_mixed_case)
{
Password my_password;
bool actual = my_password.has_mixed_case("12345");
ASSERT_FALSE(actual);
}
TEST(PasswordTest, symbols_with_upper_and_lower_return_true)
{
Password my_password;
bool actual = my_password.has_mixed_case("A!b@");
ASSERT_TRUE(actual);
}