Skip to content

Commit 995f84e

Browse files
committed
Adding tests for "Largest number".
1 parent c6e9584 commit 995f84e

File tree

8 files changed

+123
-0
lines changed

8 files changed

+123
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
3131
- Tests for "Morellet’s random lines".
3232
- Tests for "Decode the message".
3333
- Tests for "Detective geek".
34+
- Tests for "Largest number".
3435

3536
## [3.9.0] - 2022-06-01
3637
### 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\LargestNumber;
6+
7+
use CyrilVerloop\Codingame\Puzzle;
8+
9+
/**
10+
* The "Largest number" puzzle.
11+
* @link https://www.codingame.com/ide/puzzle/largest-number
12+
*/
13+
class LargestNumber implements Puzzle
14+
{
15+
public function execute($stdin): void
16+
{
17+
fscanf($stdin, "%d", $number);
18+
fscanf($stdin, "%d", $D);
19+
20+
// Write an answer using echo(). DON'T FORGET THE TRAILING \n
21+
22+
echo("answer\n");
23+
}
24+
}
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\Easy\LargestNumber;
6+
7+
use CyrilVerloop\Codingame\Tests\PuzzleTest;
8+
use CyrilVerloop\Codingame\Community\Training\Easy\LargestNumber\LargestNumber;
9+
10+
/**
11+
* Tests for the "Largest number" puzzle.
12+
*
13+
* @covers \CyrilVerloop\Codingame\Community\Training\Easy\LargestNumber\LargestNumber
14+
* @group largestNumber
15+
* @medium
16+
*/
17+
final class CGTest extends PuzzleTest
18+
{
19+
public function setUp(): void
20+
{
21+
$this->puzzle = new LargestNumber();
22+
}
23+
24+
/**
25+
* Test that the code can be executed for "No change required".
26+
*
27+
* @group largestNumber_noChangeRequired
28+
*/
29+
public function testCanExecuteNoChangeRequired(): void
30+
{
31+
$this->expectExecuteOutputAnswer(
32+
__DIR__ . '/input/01 - no change required.txt',
33+
3141 . PHP_EOL
34+
);
35+
}
36+
37+
/**
38+
* Test that the code can be executed for "Remove 1 digit".
39+
*
40+
* @group largestNumber_remove1Digit
41+
*/
42+
public function testCanExecuteRemove1Digit(): void
43+
{
44+
$this->expectExecuteOutputAnswer(
45+
__DIR__ . '/input/02 - remove 1 digit.txt',
46+
7265 . PHP_EOL
47+
);
48+
}
49+
50+
/**
51+
* Test that the code can be executed for "Remove 2 digits".
52+
*
53+
* @group largestNumber_remove2Digits
54+
*/
55+
public function testCanExecuteRemove2Digits(): void
56+
{
57+
$this->expectExecuteOutputAnswer(
58+
__DIR__ . '/input/03 - remove 2 digits.txt',
59+
4890600 . PHP_EOL
60+
);
61+
}
62+
63+
/**
64+
* Test that the code can be executed for "No solution".
65+
*
66+
* @group largestNumber_noSolution
67+
*/
68+
public function testCanExecuteNoSolution(): void
69+
{
70+
$this->expectExecuteOutputAnswer(
71+
__DIR__ . '/input/04 - no solution.txt',
72+
0 . PHP_EOL
73+
);
74+
}
75+
76+
/**
77+
* Test that the code can be executed for "Final test".
78+
*
79+
* @group largestNumber_finalTest
80+
*/
81+
public function testCanExecuteFinalTest(): void
82+
{
83+
$this->expectExecuteOutputAnswer(
84+
__DIR__ . '/input/05 - final test.txt',
85+
67537905 . PHP_EOL
86+
);
87+
}
88+
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
3141
2+
3
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
72659
2+
5
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
104890600
2+
9
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
529307543
2+
8
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
675379052
2+
3

0 commit comments

Comments
 (0)