Skip to content

Commit 7fcf305

Browse files
committed
Adding tests for "Murder in the village!".
1 parent 2360048 commit 7fcf305

File tree

11 files changed

+160
-0
lines changed

11 files changed

+160
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2525
- Tests for "Unique prefixes".
2626
- Tests for "The mystic rectangle".
2727
- Tests for "The travelling salesman problem".
28+
- Tests for "Murder in the village!".
2829

2930
## [1.7.0] - 2022-03-31
3031
### Added
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/**
2+
* The "Murder in the village!" puzzle.
3+
*/
4+
function execute(readline) {
5+
const N = parseInt(readline());
6+
for (let i = 0; i < N; i++) {
7+
const line = readline();
8+
}
9+
10+
// Write an answer using console.log()
11+
// To debug: console.error('Debug messages...');
12+
13+
console.log('It was me!');
14+
}
15+
16+
export { execute };
Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
import { assert } from 'chai';
2+
import sinon from 'sinon';
3+
import File from '../../../../File.js';
4+
import { execute } from '../../../../../lib/community/training/easy/murderInTheVillage/murderInTheVillage.js';
5+
6+
const __dirname = new URL('.', import.meta.url).pathname;
7+
8+
suite("Murder in the village!", function() {
9+
const sandbox = sinon.createSandbox();
10+
11+
setup(function () {
12+
sandbox.stub(console, "log");
13+
});
14+
15+
teardown(function () {
16+
sandbox.restore();
17+
});
18+
19+
20+
test("Test 1", function() {
21+
let inputFile = new File(__dirname + 'input/01 - test 1.txt');
22+
23+
execute(inputFile.readline.bind(inputFile));
24+
25+
assert.strictEqual(
26+
console.log.getCall(0).args[0],
27+
"It was me!"
28+
);
29+
});
30+
31+
test("Test 2", function() {
32+
let inputFile = new File(__dirname + 'input/02 - test 2.txt');
33+
34+
execute(inputFile.readline.bind(inputFile));
35+
36+
assert.strictEqual(
37+
console.log.getCall(0).args[0],
38+
"Charles did it!"
39+
);
40+
});
41+
42+
test("Test 3", function() {
43+
let inputFile = new File(__dirname + 'input/03 - test 3.txt');
44+
45+
execute(inputFile.readline.bind(inputFile));
46+
47+
assert.strictEqual(
48+
console.log.getCall(0).args[0],
49+
"Charles did it!"
50+
);
51+
});
52+
53+
test("Test 4", function() {
54+
let inputFile = new File(__dirname + 'input/04 - test 4.txt');
55+
56+
execute(inputFile.readline.bind(inputFile));
57+
58+
assert.strictEqual(
59+
console.log.getCall(0).args[0],
60+
"Lance did it!"
61+
);
62+
});
63+
64+
test("Test 5", function() {
65+
let inputFile = new File(__dirname + 'input/05 - test 5.txt');
66+
67+
execute(inputFile.readline.bind(inputFile));
68+
69+
assert.strictEqual(
70+
console.log.getCall(0).args[0],
71+
"Ben did it!"
72+
);
73+
});
74+
75+
test("Test 6", function() {
76+
let inputFile = new File(__dirname + 'input/06 - test 6.txt');
77+
78+
execute(inputFile.readline.bind(inputFile));
79+
80+
assert.strictEqual(
81+
console.log.getCall(0).args[0],
82+
"Bob did it!"
83+
);
84+
});
85+
86+
test("Test 7", function() {
87+
let inputFile = new File(__dirname + 'input/07 - test 7.txt');
88+
89+
execute(inputFile.readline.bind(inputFile));
90+
91+
assert.strictEqual(
92+
console.log.getCall(0).args[0],
93+
"Hank did it!"
94+
);
95+
});
96+
97+
test("Test 8", function() {
98+
let inputFile = new File(__dirname + 'input/08 - test 8.txt');
99+
100+
execute(inputFile.readline.bind(inputFile));
101+
102+
assert.strictEqual(
103+
console.log.getCall(0).args[0],
104+
"Dylan did it!"
105+
);
106+
});
107+
});
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
4
2+
Tom: I was in the church with Bob.
3+
Jane: I was in the garden with Joyce.
4+
Bob: I was in the church with Tom.
5+
Joyce: I was in the garden with Jane.
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
3
2+
Jordan: I was in the greenhouse with Ryan.
3+
Ryan: I was in the greenhouse with Jordan.
4+
Charles: I was in the greenhouse with Ryan and Jordan.
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
5
2+
Henry: I was in the garden with Jenny and Penny and Bill.
3+
Bill: I was in the garden with Jenny and Penny and Henry.
4+
Jenny: I was in the garden with Penny and Henry and Bill.
5+
Charles: I was in the garden with Penny and Henry and Bill and Jenny.
6+
Penny: I was in the garden with Henry and Bill and Jenny.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
2
2+
Lance: I was in the garden with Lily.
3+
Lily: I was in the garden, alone.
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
3
2+
Jane: I was in the school, alone.
3+
Lois: I was in the garden, alone.
4+
Ben: I was in the church with Jane and Lois.
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
3
2+
Tom: I was in the garden with Lily.
3+
Lily: I was in the garden with Tom.
4+
Bob: I was in the garden, alone.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
4
2+
Bob: I was in the pub with Sue.
3+
Sue: I was in the pub with Bob.
4+
Dylan: I was in the garden, alone.
5+
Hank: I was in the pub with Sue and Bob.

0 commit comments

Comments
 (0)