Skip to content

Commit 3932446

Browse files
committed
Adding tests for "Crossword".
1 parent fdc93c7 commit 3932446

24 files changed

+327
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
3030
- Tests for "Circular automation, the period of chaos".
3131
- Tests for "Minimax exercise".
3232
- Tests for "Constrained latin squares".
33+
- Tests for "Crossword".
3334

3435
## [3.11.0] - 2022-07-31
3536
### Added
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace CyrilVerloop\Codingame\Community\Training\Medium\Crossword;
6+
7+
use CyrilVerloop\Codingame\Puzzle;
8+
9+
/**
10+
* The "Crossword" puzzle.
11+
* @link https://www.codingame.com/ide/puzzle/crossword
12+
*/
13+
class Crossword implements Puzzle
14+
{
15+
public function execute($stdin): void
16+
{
17+
$H1 = stream_get_line($stdin, 256 + 1, "\n");
18+
$H2 = stream_get_line($stdin, 256 + 1, "\n");
19+
$V1 = stream_get_line($stdin, 256 + 1, "\n");
20+
$V2 = stream_get_line($stdin, 256 + 1, "\n");
21+
22+
// Write an answer using echo(). DON'T FORGET THE TRAILING \n
23+
24+
echo("answer\n");
25+
}
26+
}
Lines changed: 192 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,192 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace CyrilVerloop\Codingame\Tests\Community\Training\Medium\Crossword;
6+
7+
use CyrilVerloop\Codingame\Tests\PuzzleTest;
8+
use CyrilVerloop\Codingame\Community\Training\Medium\Crossword\Crossword;
9+
10+
/**
11+
* Tests for the "Crossword" puzzle.
12+
*
13+
* @covers \CyrilVerloop\Codingame\Community\Training\Medium\Crossword\Crossword
14+
* @group crossword
15+
* @medium
16+
*/
17+
final class CGTest extends PuzzleTest
18+
{
19+
public function setUp(): void
20+
{
21+
$this->puzzle = new Crossword();
22+
}
23+
24+
/**
25+
* Test that the code can be executed for "Byte-sized philosophy".
26+
*
27+
* @group crossword_byteSizedPhilosophy
28+
*/
29+
public function testCanExecuteByteSizedPhilosophy(): void
30+
{
31+
$this->expectExecuteOutputAnswer(
32+
__DIR__ . '/input/01 - byte-sized philosophy.txt',
33+
file_get_contents(__DIR__ . '/output/01 - byte-sized philosophy.txt')
34+
);
35+
}
36+
37+
/**
38+
* Test that the code can be executed for "Color mix".
39+
*
40+
* @group crossword_colorMix
41+
*/
42+
public function testCanExecuteColorMix(): void
43+
{
44+
$this->expectExecuteOutputAnswer(
45+
__DIR__ . '/input/02 - color mix.txt',
46+
file_get_contents(__DIR__ . '/output/02 - color mix.txt')
47+
);
48+
}
49+
50+
/**
51+
* Test that the code can be executed for "Crime scene".
52+
*
53+
* @group crossword_crimeScene
54+
*/
55+
public function testCanExecuteCrimeScene(): void
56+
{
57+
$this->expectExecuteOutputAnswer(
58+
__DIR__ . '/input/03 - crime scene.txt',
59+
file_get_contents(__DIR__ . '/output/03 - crime scene.txt')
60+
);
61+
}
62+
63+
/**
64+
* Test that the code can be executed for "Fruit salad".
65+
*
66+
* @group crossword_fruitSalad
67+
*/
68+
public function testCanExecuteFruitSalad(): void
69+
{
70+
$this->expectExecuteOutputAnswer(
71+
__DIR__ . '/input/04 - fruit salad.txt',
72+
file_get_contents(__DIR__ . '/output/04 - fruit salad.txt')
73+
);
74+
}
75+
76+
/**
77+
* Test that the code can be executed for "French writers 17th century".
78+
*
79+
* @group crossword_frenchWriters17thCentury
80+
*/
81+
public function testCanExecuteFrenchWriters17thCentury(): void
82+
{
83+
$this->expectExecuteOutputAnswer(
84+
__DIR__ . '/input/05 - french writers 17th century.txt',
85+
file_get_contents(__DIR__ . '/output/05 - french writers 17th century.txt')
86+
);
87+
}
88+
89+
/**
90+
* Test that the code can be executed for "Marvel series".
91+
*
92+
* @group crossword_marvelSeries
93+
*/
94+
public function testCanExecuteMarvelSeries(): void
95+
{
96+
$this->expectExecuteOutputAnswer(
97+
__DIR__ . '/input/06 - marvel series.txt',
98+
file_get_contents(__DIR__ . '/output/06 - marvel series.txt')
99+
);
100+
}
101+
102+
/**
103+
* Test that the code can be executed for "French coding game menu".
104+
*
105+
* @group depotOrganization_frenchCodingGameMenu
106+
*/
107+
public function testCanExecuteFrenchCodingGameMenu(): void
108+
{
109+
$this->expectExecuteOutputAnswer(
110+
__DIR__ . '/input/07 - french coding game menu.txt',
111+
19 . PHP_EOL
112+
);
113+
}
114+
115+
/**
116+
* Test that the code can be executed for "No way !".
117+
*
118+
* @group depotOrganization_noWay
119+
*/
120+
public function testCanExecuteNoWay(): void
121+
{
122+
$this->expectExecuteOutputAnswer(
123+
__DIR__ . '/input/08 - no way !.txt',
124+
0 . PHP_EOL
125+
);
126+
}
127+
128+
/**
129+
* Test that the code can be executed for "Crash test".
130+
*
131+
* @group depotOrganization_crashTest
132+
*/
133+
public function testCanExecuteCrashTest(): void
134+
{
135+
$this->expectExecuteOutputAnswer(
136+
__DIR__ . '/input/09 - crash test.txt',
137+
0 . PHP_EOL
138+
);
139+
}
140+
141+
/**
142+
* Test that the code can be executed for "Base case test".
143+
*
144+
* @group crossword_baseCaseTest
145+
*/
146+
public function testCanExecuteBaseCaseTest(): void
147+
{
148+
$this->expectExecuteOutputAnswer(
149+
__DIR__ . '/input/10 - base case test.txt',
150+
file_get_contents(__DIR__ . '/output/10 - base case test.txt')
151+
);
152+
}
153+
154+
/**
155+
* Test that the code can be executed for "Proximity test".
156+
*
157+
* @group crossword_proximityTest
158+
*/
159+
public function testCanExecuteProximityTest(): void
160+
{
161+
$this->expectExecuteOutputAnswer(
162+
__DIR__ . '/input/11 - proximity test.txt',
163+
file_get_contents(__DIR__ . '/output/11 - proximity test.txt')
164+
);
165+
}
166+
167+
/**
168+
* Test that the code can be executed for "No match test".
169+
*
170+
* @group depotOrganization_noMatchTest
171+
*/
172+
public function testCanExecuteNoMatchTest(): void
173+
{
174+
$this->expectExecuteOutputAnswer(
175+
__DIR__ . '/input/12 - no match test.txt',
176+
0 . PHP_EOL
177+
);
178+
}
179+
180+
/**
181+
* Test that the code can be executed for "Multiple solutions test".
182+
*
183+
* @group depotOrganization_multipleSolutionsTest
184+
*/
185+
public function testCanExecuteMultipleSolutionsTest(): void
186+
{
187+
$this->expectExecuteOutputAnswer(
188+
__DIR__ . '/input/13 - multiple solutions test.txt',
189+
4 . PHP_EOL
190+
);
191+
}
192+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
SIN
2+
BUT
3+
SOB
4+
NOT
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
GREEN
2+
YELLOW
3+
ORANGE
4+
INDIGO
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
HEIST
2+
ROBBERY
3+
MONEY
4+
THEFT
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
PINEAPPLE
2+
BANANA
3+
LEMON
4+
RASPBERRY
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
CORNEILLE
2+
BOILEAU
3+
RACINE
4+
MOLIERE
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
JESSICAJONES
2+
DAREDEVIL
3+
LUKECAGE
4+
IRONFIST
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
ENTRAINEMENT
2+
COMPETITION
3+
CONTRIBUTION
4+
APPRENDRE

0 commit comments

Comments
 (0)