Skip to content

Commit 79319fc

Browse files
committed
Adding tests for "Linear Bézier curves".
1 parent 938040a commit 79319fc

15 files changed

+334
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
3434
- Tests for "Bulk email generator".
3535
- Tests for "Snail run".
3636
- Tests for "Sweet spot".
37+
- Tests for "Linear Bézier curves".
3738

3839
## [3.8.0] - 2022-04-30
3940
### Added
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace CyrilVerloop\Codingame\Community\Training\Easy\LinearBezierCurves;
6+
7+
use CyrilVerloop\Codingame\Puzzle;
8+
9+
/**
10+
* The "Linear Bézier curves" puzzle.
11+
* @link https://www.codingame.com/ide/puzzle/linear-bezier-curves
12+
*/
13+
class LinearBezierCurves implements Puzzle
14+
{
15+
public function execute($stdin): void
16+
{
17+
fscanf($stdin, "%d %d", $width, $height);
18+
fscanf($stdin, "%d", $steps);
19+
fscanf($stdin, "%d %d", $ax, $ay);
20+
fscanf($stdin, "%d %d", $bx, $by);
21+
fscanf($stdin, "%d %d", $cx, $cy);
22+
fscanf($stdin, "%d %d", $dx, $dy);
23+
for ($i = 0; $i < $height; $i++)
24+
{
25+
26+
// Write an answer using echo(). DON'T FORGET THE TRAILING \n
27+
28+
echo("curve\n");
29+
}
30+
}
31+
}
Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace CyrilVerloop\Codingame\Tests\Community\Training\Easy\LinearBezierCurves;
6+
7+
use CyrilVerloop\Codingame\Tests\PuzzleTest;
8+
use CyrilVerloop\Codingame\Community\Training\Easy\LinearBezierCurves\LinearBezierCurves;
9+
10+
/**
11+
* Tests for the "Linear Bézier curves" puzzle.
12+
*
13+
* @covers \CyrilVerloop\Codingame\Community\Training\Easy\LinearBezierCurves\LinearBezierCurves
14+
* @group linearBezierCurves
15+
* @medium
16+
*/
17+
final class CGTest extends PuzzleTest
18+
{
19+
public function setUp(): void
20+
{
21+
$this->puzzle = new LinearBezierCurves();
22+
}
23+
24+
/**
25+
* Test that the code can be executed for "Simple with low resolution".
26+
*
27+
* @group linearBezierCurves_simpleWithLowResolution
28+
*/
29+
public function testCanExecuteSimpleWithLowResolution(): void
30+
{
31+
$this->expectExecuteOutputAnswer(
32+
__DIR__ . '/input/01 - simple with low resolution.txt',
33+
file_get_contents(__DIR__ . '/output/01 - simple with low resolution.txt')
34+
);
35+
}
36+
37+
/**
38+
* Test that the code can be executed for "Inverted control points".
39+
*
40+
* @group linearBezierCurves_invertedControlPoints
41+
*/
42+
public function testCanExecuteInvertedControlPoints(): void
43+
{
44+
$this->expectExecuteOutputAnswer(
45+
__DIR__ . '/input/02 - inverted control points.txt',
46+
file_get_contents(__DIR__ . '/output/02 - inverted control points.txt')
47+
);
48+
}
49+
50+
/**
51+
* Test that the code can be executed for "Close loop".
52+
*
53+
* @group linearBezierCurves_closeLoop
54+
*/
55+
public function testCanExecuteCloseLoop(): void
56+
{
57+
$this->expectExecuteOutputAnswer(
58+
__DIR__ . '/input/03 - close loop.txt',
59+
file_get_contents(__DIR__ . '/output/03 - close loop.txt')
60+
);
61+
}
62+
63+
/**
64+
* Test that the code can be executed for "Only extremes".
65+
*
66+
* @group linearBezierCurves_onlyExtremes
67+
*/
68+
public function testCanExecuteOnlyExtremes(): void
69+
{
70+
$this->expectExecuteOutputAnswer(
71+
__DIR__ . '/input/04 - only extremes.txt',
72+
file_get_contents(__DIR__ . '/output/04 - only extremes.txt')
73+
);
74+
}
75+
76+
/**
77+
* Test that the code can be executed for "High resolution".
78+
*
79+
* @group linearBezierCurves_highResolution
80+
*/
81+
public function testCanExecuteHighResolution(): void
82+
{
83+
$this->expectExecuteOutputAnswer(
84+
__DIR__ . '/input/05 - high resolution.txt',
85+
file_get_contents(__DIR__ . '/output/05 - high resolution.txt')
86+
);
87+
}
88+
89+
/**
90+
* Test that the code can be executed for "High resolution 2".
91+
*
92+
* @group linearBezierCurves_highResolution2
93+
*/
94+
public function testCanExecuteHighResolution2(): void
95+
{
96+
$this->expectExecuteOutputAnswer(
97+
__DIR__ . '/input/06 - high resolution 2.txt',
98+
file_get_contents(__DIR__ . '/output/06 - high resolution 2.txt')
99+
);
100+
}
101+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
10 10
2+
10
3+
0 0
4+
0 9
5+
9 9
6+
9 0
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
20 20
2+
25
3+
0 0
4+
19 19
5+
0 19
6+
19 0
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
30 30
2+
20
3+
5 2
4+
3 29
5+
29 15
6+
5 2
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
15 15
2+
2
3+
12 5
4+
3 14
5+
1 2
6+
3 9
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
50 50
2+
100
3+
10 47
4+
2 1
5+
45 3
6+
1 35
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
50 40
2+
100
3+
0 38
4+
30 26
5+
1 2
6+
49 0
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)