Skip to content

Commit d45483f

Browse files
committed
Adding tests for "Lunar lockout".
1 parent b02c4e1 commit d45483f

File tree

13 files changed

+175
-0
lines changed

13 files changed

+175
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
3333
- Tests for "Minesweeper level generator".
3434
- Tests for "In stereo".
3535
- Tests for "Hooch clash".
36+
- Tests for "Lunar lockout".
3637

3738
### Changed
3839
- Renaming "Linear Bézier curves" to "Cubic Bézier curves".
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\LunarLockout;
6+
7+
use CyrilVerloop\Codingame\Puzzle;
8+
9+
/**
10+
* The "Lunar lockout" puzzle.
11+
* @link https://www.codingame.com/ide/puzzle/lunar-lockout
12+
*/
13+
class LunarLockout implements Puzzle
14+
{
15+
public function execute($stdin): void
16+
{
17+
for ($i = 0; $i < 5; $i++)
18+
{
19+
$line = stream_get_line($stdin, 5 + 1, "\n");
20+
}
21+
22+
// Write an answer using echo(). DON'T FORGET THE TRAILING \n
23+
24+
echo("BU DL XU\n");
25+
}
26+
}
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace CyrilVerloop\Codingame\Tests\Community\Training\Medium\LunarLockout;
6+
7+
use CyrilVerloop\Codingame\Tests\PuzzleTest;
8+
use CyrilVerloop\Codingame\Community\Training\Medium\LunarLockout\LunarLockout;
9+
10+
/**
11+
* Tests for the "Lunar lockout" puzzle.
12+
*
13+
* @covers \CyrilVerloop\Codingame\Community\Training\Medium\LunarLockout\LunarLockout
14+
* @group lunarLockout
15+
* @medium
16+
*/
17+
final class CGTest extends PuzzleTest
18+
{
19+
public function setUp(): void
20+
{
21+
$this->puzzle = new LunarLockout();
22+
}
23+
24+
/**
25+
* Test that the code can be executed for "One move".
26+
*
27+
* @group lunarLockout_oneMove
28+
*/
29+
public function testCanExecuteOneMove(): void
30+
{
31+
$this->expectExecuteOutputAnswer(
32+
__DIR__ . '/input/01 - one move.txt',
33+
file_get_contents(__DIR__ . '/output/01 - one move.txt')
34+
);
35+
}
36+
37+
/**
38+
* Test that the code can be executed for "A little more movement".
39+
*
40+
* @group lunarLockout_aLittleMoreMovement
41+
*/
42+
public function testCanExecuteALittleMoreMovement(): void
43+
{
44+
$this->expectExecuteOutputAnswer(
45+
__DIR__ . '/input/02 - a little more movement.txt',
46+
file_get_contents(__DIR__ . '/output/02 - a little more movement.txt')
47+
);
48+
}
49+
50+
/**
51+
* Test that the code can be executed for "A few more moves".
52+
*
53+
* @group lunarLockout_aFewMoreMoves
54+
*/
55+
public function testCanExecuteAFewMoreMoves(): void
56+
{
57+
$this->expectExecuteOutputAnswer(
58+
__DIR__ . '/input/03 - a few more moves.txt',
59+
file_get_contents(__DIR__ . '/output/03 - a few more moves.txt')
60+
);
61+
}
62+
63+
/**
64+
* Test that the code can be executed for "Many more movements".
65+
*
66+
* @group lunarLockout_manyMoreMovements
67+
*/
68+
public function testCanExecuteManyMoreMovements(): void
69+
{
70+
$this->expectExecuteOutputAnswer(
71+
__DIR__ . '/input/04 - many more movements.txt',
72+
file_get_contents(__DIR__ . '/output/04 - many more movements.txt')
73+
);
74+
}
75+
76+
/**
77+
* Test that the code can be executed for "The maximum of movements".
78+
*
79+
* @group lunarLockout_theMaximumOfMovements
80+
*/
81+
public function testCanExecuteTheMaximumOfMovements(): void
82+
{
83+
$this->expectExecuteOutputAnswer(
84+
__DIR__ . '/input/05 - the maximum of movements.txt',
85+
file_get_contents(__DIR__ . '/output/05 - the maximum of movements.txt')
86+
);
87+
}
88+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
.....
2+
A.D..
3+
.C...
4+
..X..
5+
B....
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
...B.
2+
.....
3+
X....
4+
....C
5+
A....
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
.A...
2+
....C
3+
X....
4+
.....
5+
...BD
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
A.D..
2+
B....
3+
....E
4+
C..X.
5+
.....
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
AD..E
2+
B....
3+
.....
4+
.....
5+
C...X
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
XU
2+
3+
.....
4+
A.D..
5+
.CX..
6+
.....
7+
B....
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
AU AR BD XR
2+
3+
.....
4+
.....
5+
..XB.
6+
...AC
7+
.....

0 commit comments

Comments
 (0)