Skip to content

Commit aed1040

Browse files
committed
Adding tests for "The resistance".
1 parent 7ae10db commit aed1040

File tree

9 files changed

+9584
-1
lines changed

9 files changed

+9584
-1
lines changed

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ 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]
7+
## [1.4.0] - 2022-03-03
88
### Added
99
- Tests for "Blunder - episode 2".
1010
- Tests for "Blunder - episode 3".
@@ -15,6 +15,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1515
- Tests for "TAN network".
1616
- Tests for "Winamax".
1717
- Tests for "Music scores".
18+
- Tests for "The resistance".
1819

1920
## [1.3.0] - 2022-03-02
2021
### Added
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/**
2+
* The "The resistance" puzzle.
3+
*/
4+
function execute(readline) {
5+
const L = readline();
6+
const N = parseInt(readline());
7+
for (let i = 0; i < N; i++) {
8+
const W = readline();
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: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
import { assert } from 'chai';
2+
import sinon from 'sinon';
3+
import File from '../../../File.js';
4+
import { execute } from '../../../../lib/training/expert/theResistance/theResistance.js';
5+
6+
/**
7+
* Tests for the "The resistance" puzzle.
8+
*/
9+
suite('The resistance', 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('Correct detection of a letter', function() {
22+
let inputFile = new File('./test/training/expert/theResistance/input/01 - correct detection of a letter.txt');
23+
24+
execute(inputFile.readline.bind(inputFile));
25+
26+
assert.strictEqual(
27+
console.log.getCall(0).args[0],
28+
1
29+
);
30+
});
31+
32+
test('Correct detection of a word', function() {
33+
let inputFile = new File('./test/training/expert/theResistance/input/02 - correct detection of a word.txt');
34+
35+
execute(inputFile.readline.bind(inputFile));
36+
37+
assert.strictEqual(
38+
console.log.getCall(0).args[0],
39+
1
40+
);
41+
});
42+
43+
test('Simple messages', function() {
44+
let inputFile = new File('./test/training/expert/theResistance/input/03 - simple messages.txt');
45+
46+
execute(inputFile.readline.bind(inputFile));
47+
48+
assert.strictEqual(
49+
console.log.getCall(0).args[0],
50+
2
51+
);
52+
});
53+
54+
test('Long sequence, large dictionary', function() {
55+
let inputFile = new File('./test/training/expert/theResistance/input/04 - long sequence, large dictionary.txt');
56+
57+
execute(inputFile.readline.bind(inputFile));
58+
59+
assert.strictEqual(
60+
console.log.getCall(0).args[0],
61+
57330892800
62+
);
63+
});
64+
65+
test('Same encoding for different words', function() {
66+
let inputFile = new File('./test/training/expert/theResistance/input/05 - same encoding for different words.txt');
67+
68+
execute(inputFile.readline.bind(inputFile));
69+
70+
assert.strictEqual(
71+
console.log.getCall(0).args[0],
72+
125
73+
);
74+
});
75+
76+
test('Many possibilities', function() {
77+
let inputFile = new File('./test/training/expert/theResistance/input/06 - many possibilities.txt');
78+
79+
execute(inputFile.readline.bind(inputFile));
80+
81+
assert.strictEqual(
82+
console.log.getCall(0).args[0],
83+
2971215073
84+
);
85+
});
86+
});
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
-.-
2+
6
3+
A
4+
B
5+
C
6+
HELLO
7+
K
8+
WORLD
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
--.-------..
2+
5
3+
GOD
4+
GOOD
5+
MORNING
6+
G
7+
HELLO
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
......-...-..---.-----.-..-..-..
2+
5
3+
HELL
4+
HELLO
5+
OWORLD
6+
WORLD
7+
TEST

0 commit comments

Comments
 (0)