Skip to content

Commit 0f125e8

Browse files
committed
Adding tests for "Network cabling".
1 parent 9d3e826 commit 0f125e8

File tree

12 files changed

+200183
-0
lines changed

12 files changed

+200183
-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 "Network cabling".
10+
711
## [1.2.0] - 2022-03-02
812
### Added
913
- Tests for "Conway sequence".
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/**
2+
* The "Network cabling" puzzle.
3+
*/
4+
function execute(readline) {
5+
const N = parseInt(readline());
6+
for (let i = 0; i < N; i++) {
7+
var inputs = readline().split(' ');
8+
const X = parseInt(inputs[0]);
9+
const Y = parseInt(inputs[1]);
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: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
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/medium/networkCabling/networkCabling.js';
6+
7+
/**
8+
* Tests for the "Network cabling" puzzle.
9+
*/
10+
suite('Network cabling', 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 1', function() {
23+
let inputFile = new File('./test/training/medium/networkCabling/input/01 - example 1.txt');
24+
25+
execute(inputFile.readline.bind(inputFile));
26+
27+
assert.strictEqual(
28+
console.log.getCall(0).args[0],
29+
4
30+
);
31+
});
32+
33+
test('Example 2', function() {
34+
let inputFile = new File('./test/training/medium/networkCabling/input/02 - example 2.txt');
35+
36+
execute(inputFile.readline.bind(inputFile));
37+
38+
assert.strictEqual(
39+
console.log.getCall(0).args[0],
40+
4
41+
);
42+
});
43+
44+
test('Example 3', function() {
45+
let inputFile = new File('./test/training/medium/networkCabling/input/03 - example 3.txt');
46+
47+
execute(inputFile.readline.bind(inputFile));
48+
49+
assert.strictEqual(
50+
console.log.getCall(0).args[0],
51+
5
52+
);
53+
});
54+
55+
test('Example 4', function() {
56+
let inputFile = new File('./test/training/medium/networkCabling/input/04 - example 4.txt');
57+
58+
execute(inputFile.readline.bind(inputFile));
59+
60+
assert.strictEqual(
61+
console.log.getCall(0).args[0],
62+
0
63+
);
64+
});
65+
66+
test('Example 5', function() {
67+
let inputFile = new File('./test/training/medium/networkCabling/input/05 - example 5.txt');
68+
69+
execute(inputFile.readline.bind(inputFile));
70+
71+
assert.strictEqual(
72+
console.log.getCall(0).args[0],
73+
18
74+
);
75+
});
76+
77+
test('Example 6', function() {
78+
let inputFile = new File('./test/training/medium/networkCabling/input/06 - example 6.txt');
79+
80+
execute(inputFile.readline.bind(inputFile));
81+
82+
assert.strictEqual(
83+
console.log.getCall(0).args[0],
84+
6066790161
85+
);
86+
});
87+
88+
test('Example 7', function() {
89+
let inputFile = new File('./test/training/medium/networkCabling/input/07 - example 7.txt');
90+
91+
execute(inputFile.readline.bind(inputFile));
92+
93+
assert.strictEqual(
94+
console.log.getCall(0).args[0],
95+
3142894
96+
);
97+
});
98+
99+
test('Example 8', function() {
100+
let inputFile = new File('./test/training/medium/networkCabling/input/08 - example 8.txt');
101+
102+
execute(inputFile.readline.bind(inputFile));
103+
104+
assert.strictEqual(
105+
console.log.getCall(0).args[0],
106+
2500049998
107+
);
108+
});
109+
110+
test('Example 9', function() {
111+
let inputFile = new File('./test/training/medium/networkCabling/input/09 - example 9.txt');
112+
113+
execute(inputFile.readline.bind(inputFile));
114+
115+
assert.strictEqual(
116+
console.log.getCall(0).args[0],
117+
2178614523
118+
);
119+
});
120+
});
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
3
2+
0 0
3+
1 1
4+
2 2
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
3
2+
1 2
3+
0 0
4+
2 2
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
4
2+
1 2
3+
0 0
4+
2 2
5+
1 3
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
1
2+
1 1
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
3
2+
-5 -3
3+
-9 2
4+
3 -4
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
8
2+
-28189131 593661218
3+
102460950 1038903636
4+
938059973 -816049599
5+
-334087877 -290840615
6+
842560881 -116496866
7+
-416604701 690825290
8+
19715507 470868309
9+
846505116 -694479954

0 commit comments

Comments
 (0)