forked from ChicoState/TicTacToeBoard
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTicTacToeBoardTest.cpp
More file actions
112 lines (96 loc) · 2.29 KB
/
Copy pathTicTacToeBoardTest.cpp
File metadata and controls
112 lines (96 loc) · 2.29 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
/**
* Unit Tests for TicTacToeBoard
**/
#include <gtest/gtest.h>
#include "TicTacToeBoard.h"
class TicTacToeBoardTest : public ::testing::Test
{
protected:
TicTacToeBoardTest(){} //constructor runs before each test
virtual ~TicTacToeBoardTest(){} //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)
};
// EXAMPLE TEST FORMAT
TEST(TicTacToeBoardTest, sanityCheck)
{
ASSERT_TRUE(true);
}
TEST(TicTacToeBoardTest, start)
{
TicTacToeBoard B;
for(int i=0; i<BOARDSIZE; i++)
for(int j=0; j<BOARDSIZE; j++)
EXPECT_EQ(Blank, B.getPiece(i,j));
}
TEST(TicTacToeBoardTest, firstTurn)
{
TicTacToeBoard B;
B.placePiece(1,1);
ASSERT_EQ(X, B.getPiece(1,1));
B.placePiece(2,2);
ASSERT_EQ(O, B.getPiece(2,2));
}
TEST(TicTacToeBoardTest, bounds)
{
TicTacToeBoard B;
ASSERT_EQ(Invalid, B.getPiece(4,4));
ASSERT_EQ(Invalid, B.getPiece(-1,-1));
}
TEST(TicTacToeBoardTest, quickGame)
{
TicTacToeBoard B;
B.placePiece(0,0);
B.placePiece(1,0);
ASSERT_EQ(Invalid, B.getWinner());
B.placePiece(0,1);
B.placePiece(0,0);
B.placePiece(0,2);
ASSERT_EQ(X, B.getPiece(0,0));
}
TEST(TicTacToeBoardTest, full)
{
TicTacToeBoard B;
B.placePiece(0,0);
B.placePiece(0,1);
B.placePiece(0,2);
B.placePiece(1,0);
B.placePiece(1,1);
B.placePiece(1,2);
B.placePiece(2,1);
B.placePiece(2,2);
B.placePiece(2,0);
ASSERT_EQ(Blank, B.getWinner());
}
TEST(TicTacToeBoardTest, over)
{
TicTacToeBoard B;
B.placePiece(0,0);
B.placePiece(0,0);
ASSERT_EQ(X, B.getPiece(0,0));
}
TEST(TicTacToeBoardTest, row)
{
TicTacToeBoard B;
B.placePiece(7,0);
B.placePiece(0,7);
B.placePiece(7,7);
}
/*
BUG: Switched the OR's for AND's in this for loop, normally wouldn't allow and of these things when placing
a pice but will allow with bug if one holds true. Note it breaks when trying to get the pice.
*/
/*
TEST(TicTacToeBoardTest, brok)
{
TicTacToeBoard B;
B.placePiece(0,0);
ASSERT_EQ(X, B.getPiece(0,0));
B.placePiece(0,7);
ASSERT_EQ(X, B.getPiece(0,7));
B.placePiece(0,0);
ASSERT_EQ(X, B.getPiece(0,0));
B.placePiece(0,1);
ASSERT_EQ(X, B.getPiece(0,1));
}
*/