Skip to content

Commit 6b50b5b

Browse files
committed
Adding tests for "May the Triforce be with you!".
1 parent 3eef8ef commit 6b50b5b

File tree

11 files changed

+140
-0
lines changed

11 files changed

+140
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1313
- Tests for "1D spreadsheet".
1414
- Tests for "Ghost legs".
1515
- Tests for "Binary image".
16+
- Tests for "May the Triforce be with you!".
1617

1718
### Changed
1819
- "STDIN" to "$stdin" in the "Rock paper scissors lizard spock" default code.
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace CyrilVerloop\Codingame\Community\Training\Easy\MayTheTriforceBeWithYou;
6+
7+
use CyrilVerloop\Codingame\Puzzle;
8+
9+
/**
10+
* The "May the Triforce be with you!" puzzle.
11+
*/
12+
class MayTheTriforceBeWithYou implements Puzzle
13+
{
14+
public function execute($stdin): void
15+
{
16+
fscanf($stdin, "%d", $N);
17+
18+
// Write an answer using echo(). DON'T FORGET THE TRAILING \n
19+
20+
echo("answer\n");
21+
}
22+
}
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace CyrilVerloop\Codingame\Tests\Community\Training\Easy\MayTheTriforceBeWithYou;
6+
7+
use CyrilVerloop\Codingame\Tests\PuzzleTest;
8+
use CyrilVerloop\Codingame\Community\Training\Easy\MayTheTriforceBeWithYou\MayTheTriforceBeWithYou;
9+
10+
/**
11+
* Tests for the "May the Triforce be with you!" puzzle.
12+
*
13+
* @covers \CyrilVerloop\Codingame\Community\Training\Easy\MayTheTriforceBeWithYou\MayTheTriforceBeWithYou
14+
* @group mayTheTriforceBeWithYou
15+
* @medium
16+
*/
17+
final class CGTest extends PuzzleTest
18+
{
19+
public function setUp(): void
20+
{
21+
$this->puzzle = new MayTheTriforceBeWithYou();
22+
}
23+
24+
/**
25+
* Test that the code can be executed for "N = 1".
26+
*
27+
* @group mayTheTriforceBeWithYou_n1
28+
*/
29+
public function testCanExecuteN1(): void
30+
{
31+
$this->expectExecuteOutputAnswer(
32+
__DIR__ . '/input/01 - N=1.txt',
33+
file_get_contents(__DIR__ . '/output/01 - N=1.txt')
34+
);
35+
}
36+
37+
/**
38+
* Test that the code can be executed for "N = 3".
39+
*
40+
* @group mayTheTriforceBeWithYou_n3
41+
*/
42+
public function testCanExecuteN3(): void
43+
{
44+
$this->expectExecuteOutputAnswer(
45+
__DIR__ . '/input/02 - N=3.txt',
46+
file_get_contents(__DIR__ . '/output/02 - N=3.txt')
47+
);
48+
}
49+
50+
/**
51+
* Test that the code can be executed for "N = 5".
52+
*
53+
* @group mayTheTriforceBeWithYou_n5
54+
*/
55+
public function testCanExecuteN5(): void
56+
{
57+
$this->expectExecuteOutputAnswer(
58+
__DIR__ . '/input/03 - N=5.txt',
59+
file_get_contents(__DIR__ . '/output/03 - N=5.txt')
60+
);
61+
}
62+
63+
/**
64+
* Test that the code can be executed for "N = 10".
65+
*
66+
* @group mayTheTriforceBeWithYou_n10
67+
*/
68+
public function testCanExecuteN10(): void
69+
{
70+
$this->expectExecuteOutputAnswer(
71+
__DIR__ . '/input/04 - N=10.txt',
72+
file_get_contents(__DIR__ . '/output/04 - N=10.txt')
73+
);
74+
}
75+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
1
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
3
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
5
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
10
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
.*
2+
* *
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
. *
2+
***
3+
*****
4+
* *
5+
*** ***
6+
***** *****
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
. *
2+
***
3+
*****
4+
*******
5+
*********
6+
* *
7+
*** ***
8+
***** *****
9+
******* *******
10+
********* *********

0 commit comments

Comments
 (0)