-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtests.cpp
More file actions
82 lines (78 loc) · 2.01 KB
/
tests.cpp
File metadata and controls
82 lines (78 loc) · 2.01 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
/* Forward Declarations below this multiline comment:
* Allows for cyclical dependancies (This file and wordle.cpp) without
* causing recursion at the complier/linker level.
* !!Please copy any new function definitions from wordle.cpp to this file as well!!
*/
void initDisplay();
bool isValidInput(string);
vector<string> readFile(string);
void displayGuesses();
string pickWordToGuess(vector<string>);
string getGuess();
string parseGuess(const string, const string);
bool validateGuess(const string, const string);
string toLowerCase(string);
int getMenuInput();
void debugMain();
bool testToLowerCase();
bool testIsValidInput();
void debugMain(){
cout << "Testing toLowerCase function:" << endl;
if(testToLowerCase()){
cout << "All toLowerCase tests PASSED" << endl;
}
cout << "Testing isValidInput function:" << endl;
if(testIsValidInput()){
cout << "All isVaildInput tests PASSED" << endl;
}
}
bool testToLowerCase(){
string test1 = "Hello";
string test2 = "TRUCK";
string test3 = "pants";
int testsPassed = 0;
int totalTests = 3;
if(toLowerCase(test1) == "hello"){
cout << "Test 1: PASSED" << endl;
testsPassed++;
}
if(toLowerCase(test2) == "truck"){
cout << "Test 2: PASSED" << endl;
testsPassed++;
}
if(toLowerCase(test3) == "pants"){
cout << "Test 3: PASSED" << endl;
testsPassed++;
}
return testsPassed == totalTests;
}
bool testIsValidInput(){
string test1 = "hello world";
string test2 = "helloworld";
string test3 = "He$$owor$d";
string test4 = "pants";
string test5 = "truck";
int testsPassed = 0;
int totalTests = 5;
if(isValidInput(test1) == false){
cout << "Test 1: PASSED" << endl;
testsPassed++;
}
if(isValidInput(test2) == false){
cout << "Test 2: PASSED" << endl;
testsPassed++;
}
if(isValidInput(test3) == false){
cout << "Test 3: PASSED" << endl;
testsPassed++;
}
if(isValidInput(test4)){
cout << "Test 4: PASSED" << endl;
testsPassed++;
}
if(isValidInput(test5)){
cout << "Test 5: PASSED" << endl;
testsPassed++;
}
return testsPassed == totalTests;
}