-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.cpp
More file actions
187 lines (147 loc) · 4.84 KB
/
test.cpp
File metadata and controls
187 lines (147 loc) · 4.84 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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
#ifdef TESTING
#include <iostream>
#include "Dice.h"
#include "QwintoRow.h"
#include "QwintoScoreSheet.h"
#include "Player.h"
#include "QwintoPlayer.h"
#include "QwixxRow.h"
#include "QwixxScoreSheet.h"
#include "Player.h"
#include "QwixxPlayer.h"
RollOfDice rd1; //this roll of dice is used as a RNG in the random tests
Color randomColor();
void testingQwinto();
void testingQwixx();
int main(int argc, char const *argv[])
{
//filling the RNG with enough dice to have a value of at least 10
rd1.push_back(Dice(Color::RED));
rd1.push_back(Dice(Color::YELLOW));
//the actual tests
testingQwinto();
testingQwixx();
return 0;
}
void testingQwinto()
{
//Generating RollOfDice
RollOfDice rd;
rd.push_back(Dice(Color::RED));
rd.push_back(Dice(Color::YELLOW));
rd.push_back(Dice(Color::BLUE));
//Creating Test Row
QwintoRow<Color::BLUE> row;
//Creating Test ScoreSheet
QwintoScoreSheet ss("Jane Doe");
//Actual Tests
std::cout << "\nTesting Qwinto" << std::endl;
std::cout << "Testing Row\n" << std::endl;
std::cout << "Testing Print Row\n" << std::endl;
std::cout << "Expected Output: " << std::endl;
std::cout << "Red | % % |XX| % % | | | |" << std::endl;
std::cout << "Yellow | | | | | |XX| % % | |" << std::endl;
std::cout << "Blue | | % % |XX| | | | % %" << std::endl;
std::cout << "Actual Output" << std::endl;
std::cout << QwintoRow<Color::RED>();
std::cout << QwintoRow<Color::YELLOW>();
std::cout << QwintoRow<Color::BLUE>();
std::cin.get();
std::cout << "Testing operator[]\n" <<std::endl;
row[0] = 3;
std::cout << "Expected Output: " << std::endl;
std::cout << "Blue | 3| % % |XX| | | | % %" << std::endl;
std::cout << "Actual Output" << std::endl;
std::cout << row << std::endl;
std::cin.get();
std::cout << "Testing validate" <<std::endl;
row[2] = 4;
std::cout << row << std::endl;
std::cout << "Attempting to validate RollOfDice to index 1" << std::endl;
std::cout << "Expected Output" << std::endl;
std::cout << "0" << std::endl;
std::cout << "Actual Output" << std::endl;
std::cout << row.validate(1, rd) << std::endl;
std::cin.get();
std::cout << "\nTesting ScoreSheet\n" << std::endl;
std::cout << "Attempting to Fill Cells with Random RollOfDice" << std::endl;
std::cout << "All plays should be legal" << std::endl;
std::cout << "(but not necessarily smart)\n" << std::endl;
for (int i = 0; i < 100; ++i)
{
rd.roll();
ss.score(rd, randomColor(), rd1.roll()%10);
}
std::cout << ss;
}
void testingQwixx()
{
//Generating RollOfDice
RollOfDice rd;
rd.push_back(Dice(Color::RED));
rd.push_back(Dice(Color::YELLOW));
rd.push_back(Dice(Color::GREEN));
rd.push_back(Dice(Color::BLUE));
//Creating Test Row
QwixxRow<std::vector<int>, Color::RED> row;
//Creating Test ScoreSheet
QwixxScoreSheet ss("Jane Doe");
//Actual Tests
std::cout << "\nTesting Qwixx" << std::endl;
std::cout << "Testing Row\n" << std::endl;
std::cout << "Testing Print Row\n" << std::endl;
std::cout << "Expected Output: " << std::endl;
std::cout << "Red | 2| 3| 4| 5| 6| 7| 8| 9|10|11|12| U|" << std::endl;
std::cout << "Yellow | 2| 3| 4| 5| 6| 7| 8| 9|10|11|12| U|" << std::endl;
std::cout << "Green |12|11|10| 9| 8| 7| 6| 5| 4| 3| 2| U|" << std::endl;
std::cout << "Blue |12|11|10| 9| 8| 7| 6| 5| 4| 3| 2| U|" << std::endl;
std::cout << "Actual Output" << std::endl;
std::cout << QwixxRow<std::vector<int>, Color::RED>();
std::cout << QwixxRow<std::vector<int>, Color::YELLOW>();
std::cout << QwixxRow<std::list<int>, Color::GREEN>();
std::cout << QwixxRow<std::list<int>, Color::BLUE>();
std::cin.get();
std::cout << "Testing operator[]\n" <<std::endl;
row[0] = -1;
std::cout << "Expected Output: " << std::endl;
std::cout << "Red |XX| 3| 4| 5| 6| 7| 8| 9|10|11|12| U|" << std::endl;
std::cout << "Actual Output" << std::endl;
std::cout << row << std::endl;
std::cin.get();
std::cout << "Testing validate" <<std::endl;
row[0] = row[1] = row[2] = row[3] = row[8] = row[9] = -1;
std::cout << row << std::endl;
std::cout << "Attempting to validate RollOfDice to index 5" << std::endl;
std::cout << "Expected Output" << std::endl;
std::cout << "0" << std::endl;
std::cout << "Actual Output" << std::endl;
std::cout << row.validate(5, rd) << std::endl;
std::cin.get();
std::cout << "\nTesting ScoreSheet\n" << std::endl;
std::cout << "Attempting to Fill Cells with Random RollOfDice" << std::endl;
std::cout << "All plays should be legal" << std::endl;
std::cout << "(but not necessarily smart)\n" << std::endl;
for (int i = 0; i < 100; ++i)
{
rd.roll();
ss.score(rd, randomColor(), rd1.roll()%10);
}
std::cout << ss;
}
Color randomColor()
{
switch (rd1.roll()%4)
{
case 0:
return Color::RED;
case 1:
return Color::YELLOW;
case 2:
return Color::GREEN;
case 3:
return Color::BLUE;
default:
return Color::WHITE_1;
}
}
#endif