forked from exercism/php
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathConnectTest.php
More file actions
195 lines (180 loc) · 4.75 KB
/
Copy pathConnectTest.php
File metadata and controls
195 lines (180 loc) · 4.75 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
188
189
190
191
192
193
194
195
<?php
declare(strict_types=1);
use PHPUnit\Framework\Attributes\TestDox;
use PHPUnit\Framework\TestCase;
class ConnectTest extends TestCase
{
public static function setUpBeforeClass(): void
{
require_once 'Connect.php';
}
/**
* uuid 6eff0df4-3e92-478d-9b54-d3e8b354db56
*/
#[TestDox('an empty board has no winner')]
public function testEmptyBoardHasNoWinner(): void
{
$lines = [
". . . . .",
" . . . . .",
" . . . . .",
" . . . . .",
" . . . . .",
];
$this->assertEquals(null, winner($lines));
}
/**
* uuid 298b94c0-b46d-45d8-b34b-0fa2ea71f0a4
*/
#[TestDox('X can win on a 1x1 board')]
public function testOneByOneBoardBlack(): void
{
$lines = ["X"];
$this->assertEquals("black", winner($lines));
}
/**
* uuid 763bbae0-cb8f-4f28-bc21-5be16a5722dc
*/
#[TestDox('O can win on a 1x1 board')]
public function testOneByOneBoardWhite(): void
{
$lines = ["O"];
$this->assertEquals("white", winner($lines));
}
/**
* uuid 819fde60-9ae2-485e-a024-cbb8ea68751b
*/
#[TestDox('only edges does not make a winner')]
public function testOnlyEgesDoesNotMakeAWinner(): void
{
$lines = [
"O O O X",
" X . . X",
" X . . X",
" X O O O",
];
$this->assertEquals("", winner($lines));
}
/**
* uuid 2c56a0d5-9528-41e5-b92b-499dfe08506c
*/
#[TestDox('illegal diagonal does not make a winner')]
public function testIllegalDiagonalDoesNotMakeAWinner(): void
{
$lines = [
"X O . .",
" O X X X",
" O X O .",
" . O X .",
" X X O O",
];
$this->assertEquals("", winner($lines));
}
/**
* uuid 41cce3ef-43ca-4963-970a-c05d39aa1cc1
*/
#[TestDox('nobody wins crossing adjacent angles')]
public function testNobodyWinsCrossingAdjacentAngles(): void
{
$lines = [
"X . . .",
" . X O .",
" O . X O",
" . O . X",
" . . O .",
];
$this->assertEquals("", winner($lines));
}
/**
* uuid cd61c143-92f6-4a8d-84d9-cb2b359e226b
*/
#[TestDox('X wins crossing from left to right')]
public function testXWinsCrossingFromLeftToRight(): void
{
$lines = [
". O . .",
" O X X X",
" O X O .",
" X X O X",
" . O X .",
];
$this->assertEquals("black", winner($lines));
}
/**
* uuid 495e33ed-30a9-4012-b46e-d7c4d5fe13c3
*/
#[TestDox('X wins with left-hand dead end fork')]
public function testXWinsWithLeftHandDeadEndFork(): void
{
$lines = [
". . X .",
" X X . .",
" . X X X",
" O O O O",
];
$this->assertEquals("black", winner($lines));
}
/**
* uuid ab167ab0-4a98-4d0f-a1c0-e1cddddc3d58
*/
#[TestDox('X wins with right-hand dead end fork')]
public function testXWinsWithRightHandDeadEndFork(): void
{
$lines = [
". . X X",
" X X . .",
" . X X .",
" O O O O",
];
$this->assertEquals("black", winner($lines));
}
/**
* uuid 73d1eda6-16ab-4460-9904-b5f5dd401d0b
*/
#[TestDox('O wins crossing from top to bottom')]
public function testOWinsCrossingFromTopToBottom(): void
{
$lines = [
". O . .",
" O X X X",
" O O O .",
" X X O X",
" . O X .",
];
$this->assertEquals("white", winner($lines));
}
/**
* uuid c3a2a550-944a-4637-8b3f-1e1bf1340a3d
*/
#[TestDox('X wins using a convoluted path')]
public function testXWinsUsingAConvolutedPath(): void
{
$lines = [
". X X . .",
" X . X . X",
" . X . X .",
" . X X . .",
" O O O O O",
];
$this->assertEquals("black", winner($lines));
}
/**
* uuid 17e76fa8-f731-4db7-92ad-ed2a285d31f3
*/
#[TestDox('X wins using a spiral path')]
public function testXWinsUsingASpiralPath(): void
{
$lines = [
"O X X X X X X X X",
" O X O O O O O O O",
" O X O X X X X X O",
" O X O X O O O X O",
" O X O X X X O X O",
" O X O O O X O X O",
" O X X X X X O X O",
" O O O O O O O X O",
" X X X X X X X X O",
];
$this->assertEquals("black", winner($lines));
}
}