Skip to content

Commit 8f658b0

Browse files
committed
Adding tests for "Mountain map".
1 parent 45eb798 commit 8f658b0

File tree

11 files changed

+97
-0
lines changed

11 files changed

+97
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1919
- Tests for "Brackets, extreme edition".
2020
- Tests for "The electrician apprentice".
2121
- Tests for "Sudoku validator".
22+
- Tests for "Mountain map".
2223

2324
## [1.6.0] - 2022-03-11
2425
### Added
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/**
2+
* The "Mountain map" puzzle.
3+
*/
4+
function execute(readline) {
5+
const n = parseInt(readline()); // the number of mountains
6+
var inputs = readline().split(' ');
7+
for (let i = 0; i < n; i++) {
8+
const height = parseInt(inputs[i]);// height of the mountain
9+
}
10+
11+
// Write an answer using console.log()
12+
// To debug: console.error('Debug messages...');
13+
14+
console.log('answer');
15+
}
16+
17+
export { execute };
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
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/mountainMap/mountainMap.js';
6+
7+
const __dirname = new URL('.', import.meta.url).pathname;
8+
9+
suite("Mountain map", 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("Test 1", function() {
22+
let inputFile = new File(__dirname + 'input/01 - test 1.txt');
23+
24+
execute(inputFile.readline.bind(inputFile));
25+
26+
assertOutputAnswer(__dirname + 'output/01 - test 1.txt');
27+
});
28+
29+
test("Test 2", function() {
30+
let inputFile = new File(__dirname + 'input/02 - test 2.txt');
31+
32+
execute(inputFile.readline.bind(inputFile));
33+
34+
assertOutputAnswer(__dirname + 'output/02 - test 2.txt');
35+
});
36+
37+
test("Test 3", function() {
38+
let inputFile = new File(__dirname + 'input/03 - test 3.txt');
39+
40+
execute(inputFile.readline.bind(inputFile));
41+
42+
assertOutputAnswer(__dirname + 'output/03 - test 3.txt');
43+
});
44+
45+
test("Test 4", function() {
46+
let inputFile = new File(__dirname + 'input/04 - test 4.txt');
47+
48+
execute(inputFile.readline.bind(inputFile));
49+
50+
assertOutputAnswer(__dirname + 'output/04 - test 4.txt');
51+
});
52+
});
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
3
2+
1 2 1
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
1
2+
1
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
4
2+
3 7 2 9
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
7
2+
7 2 3 4 1 2 3
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
/\
2+
/\/ \/\
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/\
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
/\
2+
/ \
3+
/\ / \
4+
/ \ / \
5+
/ \ / \
6+
/ \ / \
7+
/\ / \ / \
8+
/ \ / \ /\ / \
9+
/ \/ \/ \/ \

0 commit comments

Comments
 (0)