Skip to content

Commit 49f892d

Browse files
committed
Adding tests for "TAN network".
1 parent 7212ba8 commit 49f892d

13 files changed

+17326
-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 "Roller coaster".
10+
- Tests for "TAN network".
1011

1112
## [2.5.0] - 2022-02-13
1213
### Added
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace CyrilVerloop\Codingame\Training\Hard\TANNetwork;
6+
7+
use CyrilVerloop\Codingame\Puzzle;
8+
9+
/**
10+
* The "TAN network" puzzle.
11+
*/
12+
class TANNetwork implements Puzzle
13+
{
14+
public function execute($stdin): void
15+
{
16+
fscanf($stdin, "%s", $startPoint);
17+
fscanf($stdin, "%s", $endPoint);
18+
fscanf($stdin, "%d", $N);
19+
for ($i = 0; $i < $N; $i++)
20+
{
21+
$stopName = stream_get_line($stdin, 256 + 1, "\n");
22+
}
23+
fscanf($stdin, "%d", $M);
24+
for ($i = 0; $i < $M; $i++)
25+
{
26+
$route = stream_get_line($stdin, 256 + 1, "\n");
27+
}
28+
29+
// Write an answer using echo(). DON'T FORGET THE TRAILING \n
30+
31+
echo("IMPOSSIBLE\n");
32+
}
33+
}
Lines changed: 100 additions & 0 deletions
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\Training\Hard\TANNetwork;
6+
7+
use CyrilVerloop\Codingame\Tests\PuzzleTest;
8+
use CyrilVerloop\Codingame\Training\Hard\TANNetwork\TANNetwork;
9+
10+
/**
11+
* Tests for the "TAN network" puzzle.
12+
*
13+
* @covers \CyrilVerloop\Codingame\Training\Hard\TANNetwork\TANNetwork
14+
* @group TANNetwork
15+
*/
16+
final class TANNetworkTest extends PuzzleTest
17+
{
18+
public function setUp(): void
19+
{
20+
$this->puzzle = new TANNetwork();
21+
}
22+
23+
/**
24+
* Test that the code can be executed for "Example".
25+
*
26+
* @group TANNetwork_example
27+
*/
28+
public function testCanExecuteExample(): void
29+
{
30+
$this->expectExecuteOutputAnswer(
31+
__DIR__ . '/input/01 - example.txt',
32+
file_get_contents(__DIR__ . '/output/01 - example.txt')
33+
);
34+
}
35+
36+
/**
37+
* Test that the code can be executed for "One single stop".
38+
*
39+
* @group TANNetwork_oneSingleStop
40+
*/
41+
public function testCanExecuteOneSingleStop(): void
42+
{
43+
$this->expectExecuteOutputAnswer(
44+
__DIR__ . '/input/02 - one single stop.txt',
45+
file_get_contents(__DIR__ . '/output/02 - one single stop.txt')
46+
);
47+
}
48+
49+
/**
50+
* Test that the code can be executed for "Same starting and end points".
51+
*
52+
* @group TANNetwork_startingAndEndPoints
53+
*/
54+
public function testCanExecuteSameStartingAndEndPoints(): void
55+
{
56+
$this->expectExecuteOutputAnswer(
57+
__DIR__ . '/input/03 - same starting and end points.txt',
58+
'Bonne Garde' . PHP_EOL
59+
);
60+
}
61+
62+
/**
63+
* Test that the code can be executed for "Several stages".
64+
*
65+
* @group TANNetwork_severalStages
66+
*/
67+
public function testCanExecuteSeveralStages(): void
68+
{
69+
$this->expectExecuteOutputAnswer(
70+
__DIR__ . '/input/04 - several stages.txt',
71+
file_get_contents(__DIR__ . '/output/04 - several stages.txt')
72+
);
73+
}
74+
75+
/**
76+
* Test that the code can be executed for "Large number of stages".
77+
*
78+
* @group TANNetwork_largeNumberOfStages
79+
*/
80+
public function testCanExecuteLargeNumberOfStages(): void
81+
{
82+
$this->expectExecuteOutputAnswer(
83+
__DIR__ . '/input/05 - large number of stages.txt',
84+
file_get_contents(__DIR__ . '/output/05 - large number of stages.txt')
85+
);
86+
}
87+
88+
/**
89+
* Test that the code can be executed for "Route impossible".
90+
*
91+
* @group TANNetwork_RouteImpossible
92+
*/
93+
public function testCanExecuteRouteImpossible(): void
94+
{
95+
$this->expectExecuteOutputAnswer(
96+
__DIR__ . '/input/06 - route impossible.txt',
97+
'IMPOSSIBLE' . PHP_EOL
98+
);
99+
}
100+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
StopArea:ABDU
2+
StopArea:ABLA
3+
3
4+
StopArea:ABDU,"Abel Durand",,47.22019661,-1.60337553,,,1,
5+
StopArea:ABLA,"Avenue Blanche",,47.22973509,-1.58937990,,,1,
6+
StopArea:ACHA,"Angle Chaillou",,47.26979248,-1.57206627,,,1,
7+
2
8+
StopArea:ABDU StopArea:ABLA
9+
StopArea:ABLA StopArea:ACHA

0 commit comments

Comments
 (0)