Skip to content

Commit 77da957

Browse files
committed
Adding tests for "Next car license plate ?".
1 parent fe1fefb commit 77da957

File tree

10 files changed

+153
-0
lines changed

10 files changed

+153
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
3434
- Tests for "Largest number".
3535
- Tests for "Smooth!".
3636
- Tests for "2nd degree polynomial - simple analysis".
37+
- Tests for "Next car license plate ?".
3738

3839
## [3.9.0] - 2022-06-01
3940
### Added
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace CyrilVerloop\Codingame\Community\Training\Easy\NextCarLicensePlate;
6+
7+
use CyrilVerloop\Codingame\Puzzle;
8+
9+
/**
10+
* The "Next car license plate ?" puzzle.
11+
* @link https://www.codingame.com/ide/puzzle/next-car-license-plate
12+
*/
13+
class NextCarLicensePlate implements Puzzle
14+
{
15+
public function execute($stdin): void
16+
{
17+
$x = stream_get_line($stdin, 9 + 1, "\n");
18+
fscanf($stdin, "%d", $n);
19+
20+
// Write an answer using echo(). DON'T FORGET THE TRAILING \n
21+
22+
echo("AA-000-AA\n");
23+
}
24+
}
Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace CyrilVerloop\Codingame\Tests\Community\Training\Easy\NextCarLicensePlate;
6+
7+
use CyrilVerloop\Codingame\Tests\PuzzleTest;
8+
use CyrilVerloop\Codingame\Community\Training\Easy\NextCarLicensePlate\NextCarLicensePlate;
9+
10+
/**
11+
* Tests for the "Next car license plate ?" puzzle.
12+
*
13+
* @covers \CyrilVerloop\Codingame\Community\Training\Easy\NextCarLicensePlate\NextCarLicensePlate
14+
* @group nextCarLicensePlate
15+
* @medium
16+
*/
17+
final class CGTest extends PuzzleTest
18+
{
19+
public function setUp(): void
20+
{
21+
$this->puzzle = new NextCarLicensePlate();
22+
}
23+
24+
/**
25+
* Test that the code can be executed for "+5".
26+
*
27+
* @group nextCarLicensePlate_plus5
28+
*/
29+
public function testCanExecutePlus5(): void
30+
{
31+
$this->expectExecuteOutputAnswer(
32+
__DIR__ . '/input/01 - +5.txt',
33+
"AB-128-CD" . PHP_EOL
34+
);
35+
}
36+
37+
/**
38+
* Test that the code can be executed for "+100".
39+
*
40+
* @group nextCarLicensePlate_plus100
41+
*/
42+
public function testCanExecutePlus100(): void
43+
{
44+
$this->expectExecuteOutputAnswer(
45+
__DIR__ . '/input/02 - +100.txt',
46+
"AZ-666-QS" . PHP_EOL
47+
);
48+
}
49+
50+
/**
51+
* Test that the code can be executed for "999+1".
52+
*
53+
* @group nextCarLicensePlate_999plus1
54+
*/
55+
public function testCanExecute999Plus1(): void
56+
{
57+
$this->expectExecuteOutputAnswer(
58+
__DIR__ . '/input/03 - 999+1.txt',
59+
"BN-001-GI" . PHP_EOL
60+
);
61+
}
62+
63+
/**
64+
* Test that the code can be executed for "+10000".
65+
*
66+
* @group nextCarLicensePlate_plus10000
67+
*/
68+
public function testCanExecutePlus10000(): void
69+
{
70+
$this->expectExecuteOutputAnswer(
71+
__DIR__ . '/input/04 - +10000.txt',
72+
"CG-017-CQ" . PHP_EOL
73+
);
74+
}
75+
76+
/**
77+
* Test that the code can be executed for "+100000".
78+
*
79+
* @group nextCarLicensePlate_plus100000
80+
*/
81+
public function testCanExecutePlus100000(): void
82+
{
83+
$this->expectExecuteOutputAnswer(
84+
__DIR__ . '/input/05 - +100000.txt',
85+
"IO-110-SE" . PHP_EOL
86+
);
87+
}
88+
89+
/**
90+
* Test that the code can be executed for "+1000000".
91+
*
92+
* @group nextCarLicensePlate_plus1000000
93+
*/
94+
public function testCanExecutePlus1000000(): void
95+
{
96+
$this->expectExecuteOutputAnswer(
97+
__DIR__ . '/input/06 - +1000000.txt',
98+
"QT-457-PS" . PHP_EOL
99+
);
100+
}
101+
102+
/**
103+
* Test that the code can be executed for "Very big".
104+
*
105+
* @group nextCarLicensePlate_veryBig
106+
*/
107+
public function testCanExecuteVeryBig(): void
108+
{
109+
$this->expectExecuteOutputAnswer(
110+
__DIR__ . '/input/07 - very big.txt',
111+
"JQ-027-XY" . PHP_EOL
112+
);
113+
}
114+
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
AB-123-CD
2+
5
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
AZ-566-QS
2+
100
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
BN-999-GH
2+
1
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
CG-007-CG
2+
10000
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
IO-010-OI
2+
100000
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
QS-456-DF
2+
1000000
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
ER-963-DF
2+
87654321

0 commit comments

Comments
 (0)