Skip to content

Commit 15bff9d

Browse files
committed
Adding tests for "Buzzle".
1 parent a8d5391 commit 15bff9d

17 files changed

+391
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2828
- Tests for "Nature of triangles".
2929
- Tests for "Artificial emotional intelligence".
3030
- Tests for "Park pilot".
31+
- Tests for "Buzzle".
3132

3233
### Changed
3334
- Renaming "Linear Bézier curves" to "Cubic Bézier curves".
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace CyrilVerloop\Codingame\Community\Training\Easy\Buzzle;
6+
7+
use CyrilVerloop\Codingame\Puzzle;
8+
9+
/**
10+
* The "Buzzle" puzzle.
11+
* @link https://www.codingame.com/ide/puzzle/buzzle
12+
*/
13+
class Buzzle implements Puzzle
14+
{
15+
public function execute($stdin): void
16+
{
17+
fscanf($stdin, "%d %d %d", $n, $a, $b);
18+
fscanf($stdin, "%d", $k);
19+
$inputs = explode(" ", fgets($stdin));
20+
for ($i = 0; $i < $k; $i++)
21+
{
22+
$num = intval($inputs[$i]);
23+
}
24+
25+
// Write an answer using echo(). DON'T FORGET THE TRAILING \n
26+
27+
echo("Buzzle\n");
28+
}
29+
}
Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace CyrilVerloop\Codingame\Tests\Community\Training\Easy\Buzzle;
6+
7+
use CyrilVerloop\Codingame\Tests\PuzzleTest;
8+
use CyrilVerloop\Codingame\Community\Training\Easy\Buzzle\Buzzle;
9+
10+
/**
11+
* Tests for the "Buzzle" puzzle.
12+
*
13+
* @covers \CyrilVerloop\Codingame\Community\Training\Easy\Buzzle\Buzzle
14+
* @group buzzle
15+
* @medium
16+
*/
17+
final class CGTest extends PuzzleTest
18+
{
19+
public function setUp(): void
20+
{
21+
$this->puzzle = new Buzzle();
22+
}
23+
24+
/**
25+
* Test that the code can be executed for "Test 1 - Level 1+".
26+
*
27+
* @group buzzle_test1Level1
28+
*/
29+
public function testCanExecuteTest1Level1(): void
30+
{
31+
$this->expectExecuteOutputAnswer(
32+
__DIR__ . '/input/01 - test 1 - level 1+.txt',
33+
file_get_contents(__DIR__ . '/output/01 - test 1 - level 1+.txt')
34+
);
35+
}
36+
37+
/**
38+
* Test that the code can be executed for "Test 2 - Level 2+".
39+
*
40+
* @group buzzle_test2Level2
41+
*/
42+
public function testCanExecuteTest2Level2(): void
43+
{
44+
$this->expectExecuteOutputAnswer(
45+
__DIR__ . '/input/02 - test 2 - level 2+.txt',
46+
file_get_contents(__DIR__ . '/output/02 - test 2 - level 2+.txt')
47+
);
48+
}
49+
50+
/**
51+
* Test that the code can be executed for "Test 3 - Level 3+".
52+
*
53+
* @group buzzle_test3Level3
54+
*/
55+
public function testCanExecuteTest3Level3(): void
56+
{
57+
$this->expectExecuteOutputAnswer(
58+
__DIR__ . '/input/03 - test 3 - level 3+.txt',
59+
file_get_contents(__DIR__ . '/output/03 - test 3 - level 3+.txt')
60+
);
61+
}
62+
63+
/**
64+
* Test that the code can be executed for "Test 4 - Level 4".
65+
*
66+
* @group buzzle_test4Level4
67+
*/
68+
public function testCanExecuteTest4Level4(): void
69+
{
70+
$this->expectExecuteOutputAnswer(
71+
__DIR__ . '/input/04 - test 4 - level 4.txt',
72+
file_get_contents(__DIR__ . '/output/04 - test 4 - level 4.txt')
73+
);
74+
}
75+
76+
/**
77+
* Test that the code can be executed for "Test 5 - Level 4".
78+
*
79+
* @group buzzle_test5Level4
80+
*/
81+
public function testCanExecuteTest5Level4(): void
82+
{
83+
$this->expectExecuteOutputAnswer(
84+
__DIR__ . '/input/05 - test 5 - level 4.txt',
85+
file_get_contents(__DIR__ . '/output/05 - test 5 - level 4.txt')
86+
);
87+
}
88+
89+
/**
90+
* Test that the code can be executed for "Everything is buzzle".
91+
*
92+
* @group buzzle_everythingIsBuzzle
93+
*/
94+
public function testCanExecuteEverythingIsBuzzle(): void
95+
{
96+
$this->expectExecuteOutputAnswer(
97+
__DIR__ . '/input/06 - everything is buzzle.txt',
98+
file_get_contents(__DIR__ . '/output/06 - everything is buzzle.txt')
99+
);
100+
}
101+
102+
/**
103+
* Test that the code can be executed for "Ternary".
104+
*
105+
* @group buzzle_ternary
106+
*/
107+
public function testCanExecuteTernary(): void
108+
{
109+
$this->expectExecuteOutputAnswer(
110+
__DIR__ . '/input/07 - ternary.txt',
111+
file_get_contents(__DIR__ . '/output/07 - ternary.txt')
112+
);
113+
}
114+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
10 107 114
2+
1
3+
7
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
10 26 40
2+
1
3+
7
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
10 566 588
2+
2
3+
5 9
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
18 1029 1088
2+
2
3+
11 17
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
24 4516 4586
2+
3
3+
13 19 23
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
6 128 144
2+
3
3+
3 4 5
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
3 15 46
2+
1
3+
2

0 commit comments

Comments
 (0)