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 (83 loc) · 2.14 KB
/
PasswordTest.cpp
File metadata and controls
100 lines (83 loc) · 2.14 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(){} //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;
ASSERT_EQ(1, my_password.count_leading_characters("Z"));
}
TEST(PasswordTest, mixed_case_password)
{
Password my_password;
ASSERT_EQ(2, my_password.count_leading_characters("ZZz"));
}
TEST(PasswordTest, mixed_letter_password)
{
Password my_password;
ASSERT_EQ(1, my_password.count_leading_characters("ZA"));
}
TEST(PasswordTest, mixed_case_letter_password)
{
Password my_password;
ASSERT_EQ(1, my_password.count_leading_characters("ZaA"));
}
TEST(PasswordTest, mixed_case_pass)
{
Password my_password;
ASSERT_TRUE(my_password.has_mixed_case("Za"));
}
TEST(PasswordTest, mixed_case_pass_reverse)
{
Password my_password;
ASSERT_TRUE(my_password.has_mixed_case("aZ"));
}
TEST(PasswordTest, mixed_symbol_pass)
{
Password my_password;
ASSERT_TRUE(my_password.has_mixed_case("Za%Za"));
}
TEST(PasswordTest, mixed_letter_pass)
{
Password my_password;
ASSERT_FALSE(my_password.has_mixed_case("ZA"));
}
TEST(PasswordTest, matching_case_pass)
{
Password my_password;
ASSERT_FALSE(my_password.has_mixed_case("ZZ"));
}
TEST(PasswordTest, diff_case_pass)
{
Password my_password;
ASSERT_TRUE(my_password.has_mixed_case("Zz"));
}
TEST(PasswordTest, all_unique) {
Password my_password;
ASSERT_EQ(5, my_password.unique_characters("abcde"));
}
TEST(PasswordTest, no_unique) {
Password my_password;
ASSERT_EQ(1, my_password.unique_characters("aaaaa"))
}
TEST(PasswordTest, mixed_case) {
Password my_password;
ASSERT_EQ(2, my_password.unique_characters("aAaAaA"))
}
TEST(PasswordTest, with_symbols) {
Password my_password;
ASSERT_EQ(4, my_password.unique_characters("a%&b"))
}
TEST(PasswordTest, repetition) {
Password my_password;
ASSERT_EQ(3, my_password.unique_characters("abcba"))
}