Skip to content

Commit fc5a609

Browse files
committed
Adding tests for "Rooks movements".
1 parent 2aa164c commit fc5a609

File tree

11 files changed

+162
-0
lines changed

11 files changed

+162
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77
## [Unreleased]
88
### Added
99
- Tests for "1000000000D world".
10+
- Tests for "Rooks movements".
1011

1112
## [3.4.0] - 2022-02-21
1213
### Added
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace CyrilVerloop\Codingame\Community\Training\Easy\RooksMovements;
6+
7+
use CyrilVerloop\Codingame\Puzzle;
8+
9+
/**
10+
* The "Rooks movements" puzzle.
11+
*/
12+
class RooksMovements implements Puzzle
13+
{
14+
public function execute($stdin): void
15+
{
16+
fscanf($stdin, "%s", $rookPosition);
17+
fscanf($stdin, "%d", $nbPieces);
18+
for ($i = 0; $i < $nbPieces; $i++)
19+
{
20+
fscanf($stdin, "%d %s", $colour, $onePiece);
21+
}
22+
23+
// Write an answer using echo(). DON'T FORGET THE TRAILING \n
24+
25+
echo("ANSWER\n");
26+
}
27+
}
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace CyrilVerloop\Codingame\Tests\Community\Training\Easy\RooksMovements;
6+
7+
use CyrilVerloop\Codingame\Tests\PuzzleTest;
8+
use CyrilVerloop\Codingame\Community\Training\Easy\RooksMovements\RooksMovements;
9+
10+
/**
11+
* Tests for the "Rooks movements" puzzle.
12+
*
13+
* @covers \CyrilVerloop\Codingame\Community\Training\Easy\RooksMovements\RooksMovements
14+
* @group rooksMovements
15+
* @medium
16+
*/
17+
final class CGTest extends PuzzleTest
18+
{
19+
public function setUp(): void
20+
{
21+
$this->puzzle = new RooksMovements();
22+
}
23+
24+
/**
25+
* Test that the code can be executed for "MOVING FREELY".
26+
*
27+
* @group rooksMovements_movingFreely
28+
*/
29+
public function testCanExecuteMovingFreely(): void
30+
{
31+
$this->expectExecuteOutputAnswer(
32+
__DIR__ . '/input/01 - MOVING FREELY.txt',
33+
file_get_contents(__DIR__ . '/output/01 - MOVING FREELY.txt')
34+
);
35+
}
36+
37+
/**
38+
* Test that the code can be executed for "CLOSE TO THE EDGE".
39+
*
40+
* @group rooksMovements_closeToTheEdge
41+
*/
42+
public function testCanExecuteCloseToTheEdge(): void
43+
{
44+
$this->expectExecuteOutputAnswer(
45+
__DIR__ . '/input/02 - CLOSE TO THE EDGE.txt',
46+
file_get_contents(__DIR__ . '/output/02 - CLOSE TO THE EDGE.txt')
47+
);
48+
}
49+
50+
/**
51+
* Test that the code can be executed for "ONLY ALLIES".
52+
*
53+
* @group rooksMovements_onlyAllies
54+
*/
55+
public function testCanExecuteOnlyAllies(): void
56+
{
57+
$this->expectExecuteOutputAnswer(
58+
__DIR__ . '/input/03 - ONLY ALLIES.txt',
59+
file_get_contents(__DIR__ . '/output/03 - ONLY ALLIES.txt')
60+
);
61+
}
62+
63+
/**
64+
* Test that the code can be executed for "FOR FRODOOO".
65+
*
66+
* @group rooksMovements_forFrodooo
67+
*/
68+
public function testCanExecuteForFrodooo(): void
69+
{
70+
$this->expectExecuteOutputAnswer(
71+
__DIR__ . '/input/04 - FOR FRODOOO.txt',
72+
file_get_contents(__DIR__ . '/output/04 - FOR FRODOOO.txt')
73+
);
74+
}
75+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
d5
2+
2
3+
0 c1
4+
1 e8
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
a8
2+
5
3+
0 e8
4+
1 d7
5+
0 c6
6+
1 b5
7+
0 a4
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
d5
2+
2
3+
0 g5
4+
0 d2
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
d5
2+
3
3+
0 g5
4+
0 d2
5+
1 d7
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
Rd5-a5
2+
Rd5-b5
3+
Rd5-c5
4+
Rd5-d1
5+
Rd5-d2
6+
Rd5-d3
7+
Rd5-d4
8+
Rd5-d6
9+
Rd5-d7
10+
Rd5-d8
11+
Rd5-e5
12+
Rd5-f5
13+
Rd5-g5
14+
Rd5-h5
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
Ra8-a5
2+
Ra8-a6
3+
Ra8-a7
4+
Ra8-b8
5+
Ra8-c8
6+
Ra8-d8
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
Rd5-a5
2+
Rd5-b5
3+
Rd5-c5
4+
Rd5-d3
5+
Rd5-d4
6+
Rd5-d6
7+
Rd5-d7
8+
Rd5-d8
9+
Rd5-e5
10+
Rd5-f5

0 commit comments

Comments
 (0)