Skip to content

Commit caef256

Browse files
committed
Adding tests for "Defibrillators".
1 parent 7bca3d3 commit caef256

File tree

7 files changed

+602
-0
lines changed

7 files changed

+602
-0
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.
44
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
55
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
66

7+
## [Unreleased]
8+
### Added
9+
- Tests for "Defibrillators".
10+
711
## [1.0.0] - 2022-02-26
812
### Added
913
- Base files to the project.
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/**
2+
* The "Defibrillators" puzzle.
3+
*/
4+
function execute(readline) {
5+
const LON = readline();
6+
const LAT = readline();
7+
const N = parseInt(readline());
8+
for (let i = 0; i < N; i++) {
9+
const DEFIB = readline();
10+
}
11+
12+
// Write an answer using console.log()
13+
// To debug: console.error('Debug messages...');
14+
15+
console.log('answer');
16+
}
17+
18+
export { execute };
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
import { assert } from 'chai';
2+
import sinon from 'sinon';
3+
import File from '../../../File.js';
4+
import { execute } from '../../../../lib/training/easy/defibrillators/defibrillators.js';
5+
6+
/**
7+
* Tests for the "Defibrillators" puzzle.
8+
*/
9+
suite('Defibrillators', 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('can execute "Example"', function() {
22+
let inputFile = new File('./test/training/easy/defibrillators/input/01 - example.txt');
23+
24+
execute(inputFile.readline.bind(inputFile));
25+
26+
assert.strictEqual(
27+
console.log.getCall(0).args[0],
28+
'Maison de la Prevention Sante'
29+
);
30+
});
31+
32+
test('can execute "Exact position"', function() {
33+
let inputFile = new File('./test/training/easy/defibrillators/input/02 - exact position.txt');
34+
35+
execute(inputFile.readline.bind(inputFile));
36+
37+
assert.strictEqual(
38+
console.log.getCall(0).args[0],
39+
'Cimetiere Saint-Etienne'
40+
);
41+
});
42+
43+
test('can execute "Complete file"', function() {
44+
let inputFile = new File('./test/training/easy/defibrillators/input/03 - complete file.txt');
45+
46+
execute(inputFile.readline.bind(inputFile));
47+
48+
assert.strictEqual(
49+
console.log.getCall(0).args[0],
50+
"Caisse Primaire d'Assurance Maladie"
51+
);
52+
});
53+
54+
test('can execute "Complete file 2"', function() {
55+
let inputFile = new File('./test/training/easy/defibrillators/input/04 - complete file 2.txt');
56+
57+
execute(inputFile.readline.bind(inputFile));
58+
59+
assert.strictEqual(
60+
console.log.getCall(0).args[0],
61+
"Amphitheatre d'O"
62+
);
63+
});
64+
});
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
3,879483
2+
43,608177
3+
3
4+
1;Maison de la Prevention Sante;6 rue Maguelone 340000 Montpellier;;3,87952263361082;43,6071285339217
5+
2;Hotel de Ville;1 place Georges Freche 34267 Montpellier;;3,89652239197876;43,5987299452849
6+
3;Zoo de Lunaret;50 avenue Agropolis 34090 Mtp;;3,87388031141133;43,6395872778854

test/training/easy/defibrillators/input/02 - exact position.txt

Lines changed: 170 additions & 0 deletions
Large diffs are not rendered by default.

test/training/easy/defibrillators/input/03 - complete file.txt

Lines changed: 170 additions & 0 deletions
Large diffs are not rendered by default.

test/training/easy/defibrillators/input/04 - complete file 2.txt

Lines changed: 170 additions & 0 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)