-
Notifications
You must be signed in to change notification settings - Fork 0
/
PlayerTest.cpp
72 lines (48 loc) · 1.48 KB
/
PlayerTest.cpp
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
// file PlayerTest.cpp
#include <cppunit/config/SourcePrefix.h>
#include "PlayerTest.h"
CPPUNIT_TEST_SUITE_REGISTRATION( PlayerTest );
//---------------------------------------------------------------
void PlayerTest::setUp()
{
game_m.reset();
}
//---------------------------------------------------------------
void PlayerTest::tearDown()
{
}
//---------------------------------------------------------------
void PlayerTest::checkMoves()
{
// For this test, we want to make some moves for the human
// and computer and then send a set of moves to the players
// to find if they are present
for ( int i = 1; i < 4; i++ )
game_m.addHumanMove(i);
IntSet moves;
moves.insert(1);
moves.insert(3);
moves.insert(6);
CPPUNIT_ASSERT(!human_m_p->hasMoved(moves));
game_m.addHumanMove(6);
CPPUNIT_ASSERT(human_m_p->hasMoved(moves));
CPPUNIT_ASSERT(!computer_m_p->hasMoved(moves));
// Reset the game and add some computer moves
game_m.reset();
for ( int i = 3; i < 7; i++ )
game_m.addComputerMove(i);
CPPUNIT_ASSERT(!computer_m_p->hasMoved(moves));
game_m.addComputerMove(1);
CPPUNIT_ASSERT(computer_m_p->hasMoved(moves));
}
//---------------------------------------------------------------
void PlayerTest::checkMove()
{
for ( int move = 1; move <= game_m.getSize(); move++ )
{
game_m.addHumanMove(move);
CPPUNIT_ASSERT( human_m_p->hasMoved(move) );
game_m.reset();
}
}
//---------------------------------------------------------------