-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconnectthreewidget_test.cpp
More file actions
33 lines (25 loc) · 931 Bytes
/
connectthreewidget_test.cpp
File metadata and controls
33 lines (25 loc) · 931 Bytes
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
#include "connectthreewidget.h"
// Boost.Test does not play well with -Weffc++
#include <boost/test/unit_test.hpp>
using namespace ribi;
using namespace ribi::con3;
BOOST_AUTO_TEST_CASE(play_one_game)
{
ConnectThreeWidget widget;
assert(widget.IsHuman(Player::player1));
assert(widget.IsHuman(Player::player2));
assert(widget.IsHuman(Player::player3));
assert(widget.GetGame().GetCols() == 16);
assert(widget.GetGame().GetRows() == 12);
while (widget.GetGame().GetWinner() == Winner::no_winner)
{
switch ((std::rand() >> 4) % 5)
{
case 0: widget.OnKeyPress(ConnectThreeWidget::Key::up); break;
case 1: widget.OnKeyPress(ConnectThreeWidget::Key::right); break;
case 2: widget.OnKeyPress(ConnectThreeWidget::Key::down); break;
case 3: widget.OnKeyPress(ConnectThreeWidget::Key::left); break;
case 4: widget.OnKeyPress(ConnectThreeWidget::Key::select); break;
}
}
}