Skip to content

Commit 5f06cff

Browse files
committed
Adding tests for "Regular polygons".
1 parent 3e72ff4 commit 5f06cff

File tree

8 files changed

+117
-0
lines changed

8 files changed

+117
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2222
- Tests for "Hacking at RobberCity".
2323
- Tests for "Box of cigars".
2424
- Tests for "Simplified Monopoly™ turns prediction".
25+
- Tests for "Regular polygons".
2526

2627
## [3.13.0] - 2022-09-30
2728
### Added
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace CyrilVerloop\Codingame\Community\Training\Medium\RegularPolygons;
6+
7+
use CyrilVerloop\Codingame\Puzzle;
8+
9+
/**
10+
* The "Regular polygons" puzzle.
11+
* @link https://www.codingame.com/ide/puzzle/regular-polygons
12+
*/
13+
class RegularPolygons implements Puzzle
14+
{
15+
public function execute($stdin): void
16+
{
17+
fscanf($stdin, "%d %d", $a, $b);
18+
19+
// Write an answer using echo(). DON'T FORGET THE TRAILING \n
20+
21+
echo("answer\n");
22+
}
23+
}
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\Medium\RegularPolygons;
6+
7+
use CyrilVerloop\Codingame\Tests\PuzzleTest;
8+
use CyrilVerloop\Codingame\Community\Training\Medium\RegularPolygons\RegularPolygons;
9+
10+
/**
11+
* Tests for the "Regular polygons" puzzle.
12+
*
13+
* @covers \CyrilVerloop\Codingame\Community\Training\Medium\RegularPolygons\RegularPolygons
14+
* @group regularPolygons
15+
* @medium
16+
*/
17+
final class CGTest extends PuzzleTest
18+
{
19+
public function setUp(): void
20+
{
21+
$this->puzzle = new RegularPolygons();
22+
}
23+
24+
/**
25+
* Test that the code can be executed for "Example".
26+
*
27+
* @group regularPolygons_example
28+
*/
29+
public function testCanExecuteExample(): void
30+
{
31+
$this->expectExecuteOutputAnswer(
32+
__DIR__ . '/input/01 - example.txt',
33+
4 . PHP_EOL
34+
);
35+
}
36+
37+
/**
38+
* Test that the code can be executed for "Shortest range".
39+
*
40+
* @group regularPolygons_shortestRange
41+
*/
42+
public function testCanExecuteShortestRange(): void
43+
{
44+
$this->expectExecuteOutputAnswer(
45+
__DIR__ . '/input/02 - shortest range.txt',
46+
1 . PHP_EOL
47+
);
48+
}
49+
50+
/**
51+
* Test that the code can be executed for "Short range".
52+
*
53+
* @group regularPolygons_shortRange
54+
*/
55+
public function testCanExecuteShortRange(): void
56+
{
57+
$this->expectExecuteOutputAnswer(
58+
__DIR__ . '/input/03 - short range.txt',
59+
88 . PHP_EOL
60+
);
61+
}
62+
63+
/**
64+
* Test that the code can be executed for "Medium range".
65+
*
66+
* @group regularPolygons_mediumRange
67+
*/
68+
public function testCanExecuteMediumRange(): void
69+
{
70+
$this->expectExecuteOutputAnswer(
71+
__DIR__ . '/input/04 - medium range.txt',
72+
199 . PHP_EOL
73+
);
74+
}
75+
76+
/**
77+
* Test that the code can be executed for "Long range".
78+
*
79+
* @group regularPolygons_longRange
80+
*/
81+
public function testCanExecuteLongRange(): void
82+
{
83+
$this->expectExecuteOutputAnswer(
84+
__DIR__ . '/input/05 - long range.txt',
85+
494 . PHP_EOL
86+
);
87+
}
88+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
3 6
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
17 17
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
10 10000
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
15 1000000
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
3 2147483647

0 commit comments

Comments
 (0)