Skip to content

Commit a17d502

Browse files
committed
Adding tests for "Linear Bézier curves".
1 parent f6333bb commit a17d502

15 files changed

+301
-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
### Changed
3940
- Docker Node image from "14.16.1-alpine" to "node:16.14.2-alpine".
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/**
2+
* The "Linear Bézier curves" puzzle.
3+
* @see {@link https://www.codingame.com/ide/puzzle/linear-bezier-curves}
4+
*/
5+
function execute(readline) {
6+
var inputs = readline().split(' ');
7+
const width = parseInt(inputs[0]);
8+
const height = parseInt(inputs[1]);
9+
const steps = parseInt(readline());
10+
var inputs = readline().split(' ');
11+
const ax = parseInt(inputs[0]);
12+
const ay = parseInt(inputs[1]);
13+
var inputs = readline().split(' ');
14+
const bx = parseInt(inputs[0]);
15+
const by = parseInt(inputs[1]);
16+
var inputs = readline().split(' ');
17+
const cx = parseInt(inputs[0]);
18+
const cy = parseInt(inputs[1]);
19+
var inputs = readline().split(' ');
20+
const dx = parseInt(inputs[0]);
21+
const dy = parseInt(inputs[1]);
22+
for (let i = 0; i < height; i++) {
23+
24+
// Write an answer using console.log()
25+
// To debug: console.error('Debug messages...');
26+
27+
console.log('curve');
28+
}
29+
}
30+
31+
export { execute };
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
import { assert } from 'chai';
2+
import sinon from 'sinon';
3+
import File from '../../../../File.js';
4+
import { assertOutputAnswer } from '../../../../assertOutputAnswer.js';
5+
import { execute } from '../../../../../lib/community/training/easy/linearBezierCurves/linearBezierCurves.js';
6+
7+
const __dirname = new URL('.', import.meta.url).pathname;
8+
9+
suite("Linear Bézier curves", function() {
10+
const sandbox = sinon.createSandbox();
11+
12+
setup(function () {
13+
sandbox.stub(console, "log");
14+
});
15+
16+
teardown(function () {
17+
sandbox.restore();
18+
});
19+
20+
21+
test("Simple with low resolution", function() {
22+
let inputFile = new File(__dirname + 'input/01 - simple with low resolution.txt');
23+
24+
execute(inputFile.readline.bind(inputFile));
25+
26+
assertOutputAnswer(__dirname + 'output/01 - simple with low resolution.txt');
27+
});
28+
29+
test("Inverted control points", function() {
30+
let inputFile = new File(__dirname + 'input/02 - inverted control points.txt');
31+
32+
execute(inputFile.readline.bind(inputFile));
33+
34+
assertOutputAnswer(__dirname + 'output/02 - inverted control points.txt');
35+
});
36+
37+
test("Close loop", function() {
38+
let inputFile = new File(__dirname + 'input/03 - close loop.txt');
39+
40+
execute(inputFile.readline.bind(inputFile));
41+
42+
assertOutputAnswer(__dirname + 'output/03 - close loop.txt');
43+
});
44+
45+
test("Only extremes", function() {
46+
let inputFile = new File(__dirname + 'input/04 - only extremes.txt');
47+
48+
execute(inputFile.readline.bind(inputFile));
49+
50+
assertOutputAnswer(__dirname + 'output/04 - only extremes.txt');
51+
});
52+
53+
test("High resolution", function() {
54+
let inputFile = new File(__dirname + 'input/05 - high resolution.txt');
55+
56+
execute(inputFile.readline.bind(inputFile));
57+
58+
assertOutputAnswer(__dirname + 'output/05 - high resolution.txt');
59+
});
60+
61+
test("High resolution 2", function() {
62+
let inputFile = new File(__dirname + 'input/06 - high resolution 2.txt');
63+
64+
execute(inputFile.readline.bind(inputFile));
65+
66+
assertOutputAnswer(__dirname + 'output/06 - high resolution 2.txt');
67+
});
68+
});
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)