Skip to content

Commit 10059f0

Browse files
committed
Adding tests for "Conway sequence".
1 parent 90a6950 commit 10059f0

File tree

15 files changed

+144
-0
lines changed

15 files changed

+144
-0
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ All notable changes to this project will be documented in this file.
44
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
55
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
66

7+
## [Unreleased]
8+
- Tests for "Conway sequence".
9+
710
## [2.1.0] - 2022-02-10
811
### Added
912
- Tests for "Stock exchange losses".
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\Training\Medium\ConwaySequence;
6+
7+
use CyrilVerloop\Codingame\Puzzle;
8+
9+
/**
10+
* The "Conway sequence" puzzle.
11+
*/
12+
class ConwaySequence implements Puzzle
13+
{
14+
public function execute($stdin): void
15+
{
16+
fscanf($stdin, "%d", $R);
17+
fscanf($stdin, "%d", $L);
18+
19+
// Write an answer using echo(). DON'T FORGET THE TRAILING \n
20+
21+
echo("answer\n");
22+
}
23+
}
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\Medium\ConwaySequence;
6+
7+
use CyrilVerloop\Codingame\Tests\PuzzleTest;
8+
use CyrilVerloop\Codingame\Training\Medium\ConwaySequence\ConwaySequence;
9+
10+
/**
11+
* Tests for the "Conway sequence" puzzle.
12+
*
13+
* @covers \CyrilVerloop\Codingame\Training\Medium\ConwaySequence\ConwaySequence
14+
* @group conwaySequence
15+
*/
16+
final class ConwaySequenceTest extends PuzzleTest
17+
{
18+
public function setUp(): void
19+
{
20+
$this->puzzle = new ConwaySequence();
21+
}
22+
23+
/**
24+
* Test that the code can be executed for "R=1 and L=11".
25+
*
26+
* @group conwaySequence_r1l11
27+
*/
28+
public function testCanExecuteR1L11(): void
29+
{
30+
$this->expectExecuteOutputAnswer(
31+
__DIR__ . '/input/01 - r1 l11.txt',
32+
file_get_contents(__DIR__ . '/output/01 - r1 l11.txt')
33+
);
34+
}
35+
36+
/**
37+
* Test that the code can be executed for "R=2 and L=1".
38+
*
39+
* @group conwaySequence_r2l1
40+
*/
41+
public function testCanExecuteR2L1(): void
42+
{
43+
$this->expectExecuteOutputAnswer(
44+
__DIR__ . '/input/02 - r2 l1.txt',
45+
file_get_contents(__DIR__ . '/output/02 - r2 l1.txt')
46+
);
47+
}
48+
49+
/**
50+
* Test that the code can be executed for "R=5 and L=10".
51+
*
52+
* @group conwaySequence_r5l10
53+
*/
54+
public function testCanExecuteR5L10(): void
55+
{
56+
$this->expectExecuteOutputAnswer(
57+
__DIR__ . '/input/03 - r5 l10.txt',
58+
file_get_contents(__DIR__ . '/output/03 - r5 l10.txt')
59+
);
60+
}
61+
62+
/**
63+
* Test that the code can be executed for "R=25 and L=10".
64+
*
65+
* @group conwaySequence_r25l10
66+
*/
67+
public function testCanExecuteR25L10(): void
68+
{
69+
$this->expectExecuteOutputAnswer(
70+
__DIR__ . '/input/04 - r25 l10.txt',
71+
file_get_contents(__DIR__ . '/output/04 - r25 l10.txt')
72+
);
73+
}
74+
75+
/**
76+
* Test that the code can be executed for "R=1 and L=25".
77+
*
78+
* @group conwaySequence_r1l25
79+
*/
80+
public function testCanExecuteR1L25(): void
81+
{
82+
$this->expectExecuteOutputAnswer(
83+
__DIR__ . '/input/05 - r1 l25.txt',
84+
file_get_contents(__DIR__ . '/output/05 - r1 l25.txt')
85+
);
86+
}
87+
88+
/**
89+
* Test that the code can be executed for "R=33 and L=25".
90+
*
91+
* @group conwaySequence_r33l25
92+
*/
93+
public function testCanExecuteR33L25(): void
94+
{
95+
$this->expectExecuteOutputAnswer(
96+
__DIR__ . '/input/06 - r33 l25.txt',
97+
file_get_contents(__DIR__ . '/output/06 - r33 l25.txt')
98+
);
99+
}
100+
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
1
2+
11
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
2
2+
1
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
5
2+
10
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
25
2+
10
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
1
2+
25
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
33
2+
25
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
1 1 1 3 1 2 2 1 1 3 3 1 1 2 1 3 2 1 1 3 2 1 2 2 2 1

0 commit comments

Comments
 (0)