Skip to content

Commit f7eb875

Browse files
committed
Adding tests for "Defibrillators".
1 parent 1b0d893 commit f7eb875

File tree

7 files changed

+625
-0
lines changed

7 files changed

+625
-0
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
/ci/phpunit.xml
44
/src/**/*.php
55
!/src/Training/Easy/ASCIIArt/ASCIIArt.php
6+
!/src/Training/Easy/Defibrillators/Defibrillators.php
67
!/src/Training/Easy/HorseRacingDuals/HorseRacingDuals.php
78
!/src/Training/Easy/MIMEType/MIMEType.php
89
!/src/Training/Easy/Temperatures/Temperatures.php
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\Training\Easy\Defibrillators;
6+
7+
use CyrilVerloop\Codingame\Puzzle;
8+
9+
class Defibrillators extends Puzzle
10+
{
11+
// Methods :
12+
13+
public function execute($stdin): void
14+
{
15+
fscanf($stdin, "%s", $LON);
16+
fscanf($stdin, "%s", $LAT);
17+
fscanf($stdin, "%d", $N);
18+
for ($i = 0; $i < $N; $i++)
19+
{
20+
$DEFIB = stream_get_line($stdin, 256 + 1, "\n");
21+
}
22+
23+
// Write an answer using echo(). DON'T FORGET THE TRAILING \n
24+
25+
echo("answer\n");
26+
}
27+
}
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace CyrilVerloop\Codingame\Tests\Training\Easy\Defibrillators;
6+
7+
use CyrilVerloop\Codingame\Tests\PuzzleTest;
8+
use CyrilVerloop\Codingame\Training\Easy\Defibrillators\Defibrillators;
9+
10+
/**
11+
* @coversDefaultClass \CyrilVerloop\Codingame\Training\Easy\Defibrillators\Defibrillators
12+
* @group defibrillators
13+
*/
14+
final class DefibrillatorsTest extends PuzzleTest
15+
{
16+
// Methods :
17+
18+
/**
19+
* Initialises tests.
20+
*/
21+
public function setUp(): void
22+
{
23+
$this->puzzle = new Defibrillators();
24+
}
25+
26+
/**
27+
* Test that the code can be executed for "Example".
28+
*
29+
* @covers ::execute
30+
* @group defibrillators_example
31+
*/
32+
public function testCanExecuteExample(): void
33+
{
34+
$this->expectExecuteOutputAnswer(
35+
__DIR__ . '/input/01 - example.txt',
36+
'Maison de la Prevention Sante' . PHP_EOL
37+
);
38+
}
39+
40+
/**
41+
* Test that the code can be executed for "Exact position".
42+
*
43+
* @covers ::execute
44+
* @group defibrillators_exactPosition
45+
*/
46+
public function testCanExecuteExactPosition(): void
47+
{
48+
$this->expectExecuteOutputAnswer(
49+
__DIR__ . '/input/02 - exact position.txt',
50+
'Cimetiere Saint-Etienne' . PHP_EOL
51+
);
52+
}
53+
54+
/**
55+
* Test that the code can be executed for "Complete file".
56+
*
57+
* @covers ::execute
58+
* @group defibrillators_completeFile
59+
*/
60+
public function testCanExecuteCompleteFile(): void
61+
{
62+
$this->expectExecuteOutputAnswer(
63+
__DIR__ . '/input/03 - complete file.txt',
64+
"Caisse Primaire d'Assurance Maladie" . PHP_EOL
65+
);
66+
}
67+
68+
/**
69+
* Test that the code can be executed for "Complete file 2".
70+
*
71+
* @covers ::execute
72+
* @group defibrillators_completeFile2
73+
*/
74+
public function testCanExecuteCompleteFile2(): void
75+
{
76+
$this->expectExecuteOutputAnswer(
77+
__DIR__ . '/input/04 - complete file 2.txt',
78+
"Amphitheatre d'O" . PHP_EOL
79+
);
80+
}
81+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
3,879483
2+
43,608177
3+
3
4+
1;Maison de la Prevention Sante;6 rue Maguelone 340000 Montpellier;;3,87952263361082;43,6071285339217
5+
2;Hotel de Ville;1 place Georges Freche 34267 Montpellier;;3,89652239197876;43,5987299452849
6+
3;Zoo de Lunaret;50 avenue Agropolis 34090 Mtp;;3,87388031141133;43,6395872778854

0 commit comments

Comments
 (0)