Skip to content

Commit 69a7bb5

Browse files
committed
Adding tests for "Horse-racing duals".
1 parent caef256 commit 69a7bb5

File tree

6 files changed

+100085
-0
lines changed

6 files changed

+100085
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77
## [Unreleased]
88
### Added
99
- Tests for "Defibrillators".
10+
- Tests for "Horse-racing duals".
1011

1112
## [1.0.0] - 2022-02-26
1213
### Added
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/**.
2+
* The "Horse-racing duals" puzzle.
3+
*/
4+
function execute(readline) {
5+
const N = parseInt(readline());
6+
for (let i = 0; i < N; i++) {
7+
const pi = parseInt(readline());
8+
}
9+
10+
// Write an answer using console.log()
11+
// To debug: console.error('Debug messages...');
12+
13+
console.log('answer');
14+
}
15+
16+
export { execute };
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
import { assert } from 'chai';
2+
import sinon from 'sinon';
3+
import File from '../../../File.js';
4+
import { execute } from '../../../../lib/training/easy/horseRacingDuals/horseRacingDuals.js';
5+
6+
/**
7+
* Tests for the "Horse-racing duals" puzzle.
8+
*/
9+
suite('Horse-racing duals', 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('Simple case', function() {
22+
let inputFile = new File('./test/training/easy/horseRacingDuals/input/01 - simple case.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('Horses in any order', function() {
33+
let inputFile = new File('./test/training/easy/horseRacingDuals/input/02 - horses in any order.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('Many horses', function() {
44+
let inputFile = new File('./test/training/easy/horseRacingDuals/input/03 - many horses.txt');
45+
46+
execute(inputFile.readline.bind(inputFile));
47+
48+
assert.strictEqual(
49+
console.log.getCall(0).args[0],
50+
47
51+
);
52+
});
53+
});
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
3
2+
5
3+
8
4+
9
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
10
2+
5
3+
15
4+
17
5+
3
6+
8
7+
11
8+
28
9+
6
10+
55
11+
7

0 commit comments

Comments
 (0)