Skip to content

Commit 1b319b4

Browse files
committed
Adding tests for "Conway sequence".
1 parent 841764d commit 1b319b4

File tree

15 files changed

+105
-0
lines changed

15 files changed

+105
-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 "Conway sequence".
10+
711
## [1.1.0] - 2022-02-28
812
### Added
913
- Tests for "Defibrillators".
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
/**
2+
* The "Conway sequence" puzzle.
3+
*/
4+
function execute(readline) {
5+
const R = parseInt(readline());
6+
const L = parseInt(readline());
7+
8+
// Write an answer using console.log()
9+
// To debug: console.error('Debug messages...');
10+
11+
console.log('answer');
12+
}
13+
14+
export { execute };
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
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/conwaySequence/conwaySequence.js';
6+
7+
/**
8+
* Tests for the "Conway sequence" puzzle.
9+
*/
10+
suite('Conway sequence', 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('R=1 and L=11', function() {
23+
let inputFile = new File('./test/training/medium/conwaySequence/input/01 - r1 l11.txt');
24+
25+
execute(inputFile.readline.bind(inputFile));
26+
27+
assertOutputAnswer('./test/training/medium/conwaySequence/output/01 - r1 l11.txt');
28+
});
29+
30+
test('R=2 and L=1', function() {
31+
let inputFile = new File('./test/training/medium/conwaySequence/input/02 - r2 l1.txt');
32+
33+
execute(inputFile.readline.bind(inputFile));
34+
35+
assertOutputAnswer('./test/training/medium/conwaySequence/output/02 - r2 l1.txt');
36+
});
37+
38+
test('R=5 and L=10', function() {
39+
let inputFile = new File('./test/training/medium/conwaySequence/input/03 - r5 l10.txt');
40+
41+
execute(inputFile.readline.bind(inputFile));
42+
43+
assertOutputAnswer('./test/training/medium/conwaySequence/output/03 - r5 l10.txt');
44+
});
45+
46+
test('R=25 and L=10', function() {
47+
let inputFile = new File('./test/training/medium/conwaySequence/input/04 - r25 l10.txt');
48+
49+
execute(inputFile.readline.bind(inputFile));
50+
51+
assertOutputAnswer('./test/training/medium/conwaySequence/output/04 - r25 l10.txt');
52+
});
53+
54+
test('R=1 and L=25', function() {
55+
let inputFile = new File('./test/training/medium/conwaySequence/input/05 - r1 l25.txt');
56+
57+
execute(inputFile.readline.bind(inputFile));
58+
59+
assertOutputAnswer('./test/training/medium/conwaySequence/output/05 - r1 l25.txt');
60+
});
61+
62+
test('R=33 and L=25', function() {
63+
let inputFile = new File('./test/training/medium/conwaySequence/input/06 - r33 l25.txt');
64+
65+
execute(inputFile.readline.bind(inputFile));
66+
67+
assertOutputAnswer('./test/training/medium/conwaySequence/output/06 - r33 l25.txt');
68+
});
69+
});
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
1
2+
11
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
2
2+
1
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
5
2+
10
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
25
2+
10
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
1
2+
25
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
33
2+
25
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
1 1 1 3 1 2 2 1 1 3 3 1 1 2 1 3 2 1 1 3 2 1 2 2 2 1

0 commit comments

Comments
 (0)