-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtictactoe_test.cc
39 lines (34 loc) · 945 Bytes
/
tictactoe_test.cc
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
// Tests for tictactoe.cc
//
// Author (starting point): Russ Tuck
// Authors (everything else):
#include <iostream>
using std::cout;
using std::endl;
#include "tictactoe.h"
bool tttb_winner_vertical_test() {
TictactoeBoard b;
b.set(0, 0, TictactoeXO::X);
b.set(1, 0, TictactoeXO::X);
if (TictactoeXO::X == b.winner()) {
cout << "tttb_winner_vertical_test() failed for 2 in a row" << endl;
return false;
}
b.set(2, 0, TictactoeXO::X);
if (TictactoeXO::X != b.winner()) {
cout << "tttb_winner_vertical_test() failed for 3 in a row" << endl;
return false;
}
return true;
}
// Runs tests above, and prints a message if they all pass.
// If any fail, they print their own failure messages.
int main() {
bool result = true;
result &= tttb_winner_vertical_test();
if (result) {
cout << "All tests passed." << endl;
return(0);
}
return(-1);
}