Skip to content

Commit 4a367b8

Browse files
committed
Adding tests for "May the Triforce be with you!".
1 parent e681e38 commit 4a367b8

File tree

11 files changed

+111
-0
lines changed

11 files changed

+111
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1313
- Tests for "1D spreadsheet".
1414
- Tests for "Ghost legs".
1515
- Tests for "Binary image".
16+
- Tests for "May the Triforce be with you!".
1617

1718
### Changed
1819
- Using "__dirname" for input / output paths.
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
/**
2+
* The "May the Triforce be with you!" puzzle.
3+
*/
4+
function execute(readline) {
5+
const N = parseInt(readline());
6+
7+
// Write an answer using console.log()
8+
// To debug: console.error('Debug messages...');
9+
10+
console.log('answer');
11+
}
12+
13+
export { execute };
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
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/mayTheTriforceBeWithYou/mayTheTriforceBeWithYou.js';
6+
7+
const __dirname = new URL('.', import.meta.url).pathname;
8+
9+
/**
10+
* Tests for the "May the Triforce be with you!" puzzle.
11+
*/
12+
suite('May the Triforce be with you!', function() {
13+
const sandbox = sinon.createSandbox();
14+
15+
setup(function () {
16+
sandbox.stub(console, "log");
17+
});
18+
19+
teardown(function () {
20+
sandbox.restore();
21+
});
22+
23+
24+
test('N = 1', function() {
25+
let inputFile = new File(__dirname + 'input/01 - N=1.txt');
26+
27+
execute(inputFile.readline.bind(inputFile));
28+
29+
assertOutputAnswer(__dirname + 'output/01 - N=1.txt');
30+
});
31+
32+
test('N = 3', function() {
33+
let inputFile = new File(__dirname + 'input/02 - N=3.txt');
34+
35+
execute(inputFile.readline.bind(inputFile));
36+
37+
assertOutputAnswer(__dirname + 'output/02 - N=3.txt');
38+
});
39+
40+
test('N = 5', function() {
41+
let inputFile = new File(__dirname + 'input/03 - N=5.txt');
42+
43+
execute(inputFile.readline.bind(inputFile));
44+
45+
assertOutputAnswer(__dirname + 'output/03 - N=5.txt');
46+
});
47+
48+
test('N = 10', function() {
49+
let inputFile = new File(__dirname + 'input/04 - N=10.txt');
50+
51+
execute(inputFile.readline.bind(inputFile));
52+
53+
assertOutputAnswer(__dirname + 'output/04 - N=10.txt');
54+
});
55+
});
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
1
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
3
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
5
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
10
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
.*
2+
* *
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
. *
2+
***
3+
*****
4+
* *
5+
*** ***
6+
***** *****
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)