Skip to content

Commit aa591ac

Browse files
committed
Adding tests for "The resistance".
1 parent 8433142 commit aa591ac

9 files changed

+9608
-1
lines changed

CHANGELOG.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@ 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]
7+
## [2.7.0] - 2022-02-14
88
### Added
99
- Tests for "Music scores".
10+
- Tests for "The resistance".
1011

1112
## [2.6.0] - 2022-02-14
1213
### Added
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace CyrilVerloop\Codingame\Training\Expert\TheResistance;
6+
7+
use CyrilVerloop\Codingame\Puzzle;
8+
9+
/**
10+
* The "The resistance" puzzle.
11+
*/
12+
class TheResistance implements Puzzle
13+
{
14+
public function execute($stdin): void
15+
{
16+
fscanf($stdin, "%s", $L);
17+
fscanf($stdin, "%d", $N);
18+
for ($i = 0; $i < $N; $i++)
19+
{
20+
fscanf($stdin, "%s", $W);
21+
}
22+
23+
// Write an answer using echo(). DON'T FORGET THE TRAILING \n
24+
25+
echo("answer\n");
26+
}
27+
}
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\Expert\TheResistance;
6+
7+
use CyrilVerloop\Codingame\Tests\PuzzleTest;
8+
use CyrilVerloop\Codingame\Training\Expert\TheResistance\TheResistance;
9+
10+
/**
11+
* Tests for "The resistance" puzzle.
12+
*
13+
* @covers \CyrilVerloop\Codingame\Training\Expert\TheResistance\TheResistance
14+
* @group theResistance
15+
*/
16+
final class TheResistanceTest extends PuzzleTest
17+
{
18+
public function setUp(): void
19+
{
20+
$this->puzzle = new TheResistance();
21+
}
22+
23+
/**
24+
* Test that the code can be executed for "Correct detection of a letter".
25+
*
26+
* @group theResistance_correctDetectionOfALetter
27+
*/
28+
public function testCanExecuteCorrectDetectionOfALetter(): void
29+
{
30+
$this->expectExecuteOutputAnswer(
31+
__DIR__ . '/input/01 - correct detection of a letter.txt',
32+
1 . PHP_EOL
33+
);
34+
}
35+
36+
/**
37+
* Test that the code can be executed for "Correct detection of a word".
38+
*
39+
* @group theResistance_correctDetectionOfAWord
40+
*/
41+
public function testCanExecuteCorrectDetectionOfAWord(): void
42+
{
43+
$this->expectExecuteOutputAnswer(
44+
__DIR__ . '/input/02 - correct detection of a word.txt',
45+
1 . PHP_EOL
46+
);
47+
}
48+
49+
/**
50+
* Test that the code can be executed for "Simple messages".
51+
*
52+
* @group theResistance_simpleMessages
53+
*/
54+
public function testCanExecuteSimpleMessages(): void
55+
{
56+
$this->expectExecuteOutputAnswer(
57+
__DIR__ . '/input/03 - simple messages.txt',
58+
2 . PHP_EOL
59+
);
60+
}
61+
62+
/**
63+
* Test that the code can be executed for "Long sequence, large dictionary".
64+
*
65+
* @group theResistance_longSequenceLargeDictionary
66+
*/
67+
public function testCanExecuteLongSequenceLargeDictionary(): void
68+
{
69+
$this->expectExecuteOutputAnswer(
70+
__DIR__ . '/input/04 - long sequence, large dictionary.txt',
71+
57330892800 . PHP_EOL
72+
);
73+
}
74+
75+
/**
76+
* Test that the code can be executed for "Same encoding for different words".
77+
*
78+
* @group theResistance_sameEncodingForDifferentWords
79+
*/
80+
public function testCanExecuteSameEncodingForDifferentWords(): void
81+
{
82+
$this->expectExecuteOutputAnswer(
83+
__DIR__ . '/input/05 - same encoding for different words.txt',
84+
125 . PHP_EOL
85+
);
86+
}
87+
88+
/**
89+
* Test that the code can be executed for "Many possibilities".
90+
*
91+
* @group theResistance_manyPossibilities
92+
*/
93+
public function testCanExecuteManyPossibilities(): void
94+
{
95+
$this->expectExecuteOutputAnswer(
96+
__DIR__ . '/input/06 - many possibilities.txt',
97+
2971215073 . PHP_EOL
98+
);
99+
}
100+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
-.-
2+
6
3+
A
4+
B
5+
C
6+
HELLO
7+
K
8+
WORLD
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
--.-------..
2+
5
3+
GOD
4+
GOOD
5+
MORNING
6+
G
7+
HELLO
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
......-...-..---.-----.-..-..-..
2+
5
3+
HELL
4+
HELLO
5+
OWORLD
6+
WORLD
7+
TEST

0 commit comments

Comments
 (0)