Skip to content

Commit de54b67

Browse files
committed
Adding tests for "TAN network".
1 parent 15cd24d commit de54b67

13 files changed

+17290
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1212
- Tests for "Genome sequencing".
1313
- Tests for "Roller coaster".
1414
- Tests for "Super computer".
15-
- Tests for "Surface".
15+
- Tests for "TAN network".
1616

1717
## [1.3.0] - 2022-03-02
1818
### Added
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/**
2+
* The "TAN network" puzzle.
3+
*/
4+
function execute(readline) {
5+
const startPoint = readline();
6+
const endPoint = readline();
7+
const N = parseInt(readline());
8+
for (let i = 0; i < N; i++) {
9+
const stopName = readline();
10+
}
11+
const M = parseInt(readline());
12+
for (let i = 0; i < M; i++) {
13+
const route = readline();
14+
}
15+
16+
// Write an answer using console.log()
17+
// To debug: console.error('Debug messages...');
18+
19+
console.log('IMPOSSIBLE');
20+
}
21+
22+
export { execute };
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
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/training/hard/TANNetwork/TANNetwork.js';
6+
7+
/**
8+
* Tests for the "TAN network" puzzle.
9+
*/
10+
suite('TAN network', function() {
11+
const sandbox = sinon.createSandbox();
12+
13+
setup(function () {
14+
sandbox.stub(console, "log");
15+
});
16+
17+
teardown(function () {
18+
sandbox.restore();
19+
});
20+
21+
22+
test('Example', function() {
23+
let inputFile = new File('./test/training/hard/TANNetwork/input/01 - example.txt');
24+
25+
execute(inputFile.readline.bind(inputFile));
26+
27+
assertOutputAnswer('./test/training/hard/TANNetwork/output/01 - example.txt');
28+
});
29+
30+
test('One single stop', function() {
31+
let inputFile = new File('./test/training/hard/TANNetwork/input/02 - one single stop.txt');
32+
33+
execute(inputFile.readline.bind(inputFile));
34+
35+
assertOutputAnswer('./test/training/hard/TANNetwork/output/02 - one single stop.txt');
36+
});
37+
38+
test('Same starting and end points', function() {
39+
let inputFile = new File('./test/training/hard/TANNetwork/input/03 - same starting and end points.txt');
40+
41+
execute(inputFile.readline.bind(inputFile));
42+
43+
assert.strictEqual(
44+
console.log.getCall(0).args[0],
45+
"Bonne Garde"
46+
);
47+
});
48+
49+
test('Several stages', function() {
50+
let inputFile = new File('./test/training/hard/TANNetwork/input/04 - several stages.txt');
51+
52+
execute(inputFile.readline.bind(inputFile));
53+
54+
assertOutputAnswer('./test/training/hard/TANNetwork/output/04 - several stages.txt');
55+
});
56+
57+
test('Large number of stages', function() {
58+
let inputFile = new File('./test/training/hard/TANNetwork/input/05 - large number of stages.txt');
59+
60+
execute(inputFile.readline.bind(inputFile));
61+
62+
assertOutputAnswer('./test/training/hard/TANNetwork/output/05 - large number of stages.txt');
63+
});
64+
65+
test('Route impossible', function() {
66+
let inputFile = new File('./test/training/hard/TANNetwork/input/06 - route impossible.txt');
67+
68+
execute(inputFile.readline.bind(inputFile));
69+
70+
assert.strictEqual(
71+
console.log.getCall(0).args[0],
72+
"IMPOSSIBLE"
73+
);
74+
});
75+
});
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
StopArea:ABDU
2+
StopArea:ABLA
3+
3
4+
StopArea:ABDU,"Abel Durand",,47.22019661,-1.60337553,,,1,
5+
StopArea:ABLA,"Avenue Blanche",,47.22973509,-1.58937990,,,1,
6+
StopArea:ACHA,"Angle Chaillou",,47.26979248,-1.57206627,,,1,
7+
2
8+
StopArea:ABDU StopArea:ABLA
9+
StopArea:ABLA StopArea:ACHA

test/training/hard/TANNetwork/input/02 - one single stop.txt

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

test/training/hard/TANNetwork/input/03 - same starting and end points.txt

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

test/training/hard/TANNetwork/input/04 - several stages.txt

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

test/training/hard/TANNetwork/input/05 - large number of stages.txt

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

test/training/hard/TANNetwork/input/06 - route impossible.txt

Lines changed: 3423 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Abel Durand
2+
Avenue Blanche

0 commit comments

Comments
 (0)