Skip to content

Commit 9ec7488

Browse files
committed
Adding tests for "Robot show".
1 parent 12100b6 commit 9ec7488

File tree

9 files changed

+148
-0
lines changed

9 files changed

+148
-0
lines changed

CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.
44
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
55
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
66

7+
## [3.1.0] - 2022-02-17
8+
### Added
9+
- Tests for "Robot show".
10+
711
## [3.0.0] - 2022-02-16
812
### Changed
913
- Renamed all test files to "CGTest.php".
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\Easy\RobotShow;
6+
7+
use CyrilVerloop\Codingame\Puzzle;
8+
9+
/**
10+
* The "Robot show" puzzle.
11+
*/
12+
class RobotShow implements Puzzle
13+
{
14+
public function execute($stdin): void
15+
{
16+
fscanf($stdin, "%d", $L);
17+
fscanf($stdin, "%d", $N);
18+
$inputs = explode(" ", fgets($stdin));
19+
for ($i = 0; $i < $N; $i++)
20+
{
21+
$b = intval($inputs[$i]);
22+
}
23+
24+
// Write an answer using echo(). DON'T FORGET THE TRAILING \n
25+
}
26+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace CyrilVerloop\Codingame\Tests\Community\Training\Easy\RobotShow;
6+
7+
use CyrilVerloop\Codingame\Tests\PuzzleTest;
8+
use CyrilVerloop\Codingame\Community\Training\Easy\RobotShow\RobotShow;
9+
10+
/**
11+
* Tests for the "Robot show" puzzle.
12+
*
13+
* @covers \CyrilVerloop\Codingame\Community\Training\Easy\RobotShow\RobotShow
14+
* @group robotShow
15+
*/
16+
final class CGTest extends PuzzleTest
17+
{
18+
public function setUp(): void
19+
{
20+
$this->puzzle = new RobotShow();
21+
}
22+
23+
/**
24+
* Test that the code can be executed for "Example".
25+
*
26+
* @group robotShow_example
27+
*/
28+
public function testCanExecuteExample(): void
29+
{
30+
$this->expectExecuteOutputAnswer(
31+
__DIR__ . '/input/01 - example.txt',
32+
8 . PHP_EOL
33+
);
34+
}
35+
36+
/**
37+
* Test that the code can be executed for "Simple".
38+
*
39+
* @group robotShow_simple
40+
*/
41+
public function testCanExecuteSimple(): void
42+
{
43+
$this->expectExecuteOutputAnswer(
44+
__DIR__ . '/input/02 - simple.txt',
45+
20 . PHP_EOL
46+
);
47+
}
48+
49+
/**
50+
* Test that the code can be executed for "More bots".
51+
*
52+
* @group robotShow_moreBots
53+
*/
54+
public function testCanExecuteMoreBots(): void
55+
{
56+
$this->expectExecuteOutputAnswer(
57+
__DIR__ . '/input/03 - more bots.txt',
58+
102 . PHP_EOL
59+
);
60+
}
61+
62+
/**
63+
* Test that the code can be executed for "Ping pong".
64+
*
65+
* @group robotShow_pingPong
66+
*/
67+
public function testCanExecutePingPong(): void
68+
{
69+
$this->expectExecuteOutputAnswer(
70+
__DIR__ . '/input/04 - ping pong.txt',
71+
112 . PHP_EOL
72+
);
73+
}
74+
75+
/**
76+
* Test that the code can be executed for "Traffic jam".
77+
*
78+
* @group robotShow_trafficJam
79+
*/
80+
public function testCanExecuteTrafficJam(): void
81+
{
82+
$this->expectExecuteOutputAnswer(
83+
__DIR__ . '/input/05 - traffic jam.txt',
84+
153 . PHP_EOL
85+
);
86+
}
87+
88+
/**
89+
* Test that the code can be executed for "Singular".
90+
*
91+
* @group robotShow_singular
92+
*/
93+
public function testCanExecuteSingular(): void
94+
{
95+
$this->expectExecuteOutputAnswer(
96+
__DIR__ . '/input/06 - singular.txt',
97+
7 . PHP_EOL
98+
);
99+
}
100+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
10
2+
2
3+
2 6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
20
2+
7
3+
1 2 20 7 6 10 14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
103
2+
20
3+
87 19 72 59 22 74 89 30 33 3 66 77 15 23 58 82 56 98 1 84
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
113
2+
50
3+
42 38 102 73 106 15 51 8 72 66 112 95 87 90 1 104 25 43 14 29 57 98 33 58 55 16 49 60 105 71 18 12 28 86 4 101 63 36 22 31 45 17 75 85 32 61 62 30 107 13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
156
2+
78
3+
14 127 21 15 91 121 89 105 32 136 100 95 143 112 88 147 78 48 36 114 28 33 151 9 59 11 116 134 6 39 67 50 110 102 139 49 118 30 144 4 97 56 52 73 125 115 149 66 71 42 3 61 141 81 106 101 99 137 111 133 79 43 145 84 51 107 131 12 87 104 60 126 119 146 96 7 94 10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
14
2+
1
3+
7

0 commit comments

Comments
 (0)