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
92 lines (79 loc) · 1.95 KB
/
PasswordTest.cpp
File metadata and controls
92 lines (79 loc) · 1.95 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
#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, multi_letter_password)
{
Password my_password;
int actual = my_password.count_leading_characters("Zzz");
ASSERT_EQ(2, actual);
}
TEST(PasswordTest, empty_letter_password)
{
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("aaaaaa");
ASSERT_EQ(6, actual);
}
TEST(PasswordTest, no_repetition)
{
Password my_password;
int actual = my_password.count_leading_characters("abc");
ASSERT_EQ(1, actual);
}
TEST(PasswordTest, mixed_case_true)
{
Password my_password;
bool actual = my_password.has_mixed_case("AbC");
ASSERT_TRUE(actual);
}
TEST(PasswordTest, only_uppercase)
{
Password my_password;
bool actual = my_password.has_mixed_case("ABC");
ASSERT_FALSE(actual);
}
TEST(PasswordTest, only_lowercase)
{
Password my_password;
bool actual = my_password.has_mixed_case("abc");
ASSERT_FALSE(actual);
}
TEST(PasswordTest, empty_string_mixed_case)
{
Password my_password;
bool actual = my_password.has_mixed_case("");
ASSERT_FALSE(actual);
}
TEST(PasswordTest, unique_characters_basic)
{
unsigned int actual = unique_characters("hello");
ASSERT_EQ(4, actual); // h, e, l, o
}
TEST(PasswordTest, unique_characters_all_unique)
{
unsigned int actual = unique_characters("abc");
ASSERT_EQ(3, actual);
}
TEST(PasswordTest, unique_characters_empty)
{
unsigned int actual = unique_characters("");
ASSERT_EQ(0, actual);
}