Skip to content

Commit 211ac01

Browse files
committed
Adding tests for "Next growing number".
1 parent 4a367b8 commit 211ac01

File tree

8 files changed

+97
-1
lines changed

8 files changed

+97
-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.6.0] - 2022-03-11
88
### Added
99
- Tests for "Walk on a die".
1010
- Tests for "Dolbear's law".
@@ -14,6 +14,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1414
- Tests for "Ghost legs".
1515
- Tests for "Binary image".
1616
- Tests for "May the Triforce be with you!".
17+
- Tests for "Next growing number".
1718

1819
### Changed
1920
- Using "__dirname" for input / output paths.
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
/**
2+
* The "Next growing number" puzzle.
3+
*/
4+
function execute(readline) {
5+
const n = readline();
6+
7+
// Write an answer using console.log()
8+
// To debug: console.error('Debug messages...');
9+
10+
console.log('answer');
11+
}
12+
13+
export { execute };
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
import { assert } from 'chai';
2+
import sinon from 'sinon';
3+
import File from '../../../../File.js';
4+
import { execute } from '../../../../../lib/community/training/easy/nextGrowingNumber/nextGrowingNumber.js';
5+
6+
const __dirname = new URL('.', import.meta.url).pathname;
7+
8+
/**
9+
* Tests for the "Next growing number" puzzle.
10+
*/
11+
suite('Next growing number', function() {
12+
const sandbox = sinon.createSandbox();
13+
14+
setup(function () {
15+
sandbox.stub(console, "log");
16+
});
17+
18+
teardown(function () {
19+
sandbox.restore();
20+
});
21+
22+
23+
test('Test 1', function() {
24+
let inputFile = new File(__dirname + 'input/01 - test 1.txt');
25+
26+
execute(inputFile.readline.bind(inputFile));
27+
28+
assert.strictEqual(
29+
console.log.getCall(0).args[0],
30+
22
31+
);
32+
});
33+
34+
test('Test 2', function() {
35+
let inputFile = new File(__dirname + 'input/02 - test 2.txt');
36+
37+
execute(inputFile.readline.bind(inputFile));
38+
39+
assert.strictEqual(
40+
console.log.getCall(0).args[0],
41+
111
42+
);
43+
});
44+
45+
test('Test 3', function() {
46+
let inputFile = new File(__dirname + 'input/03 - test 3.txt');
47+
48+
execute(inputFile.readline.bind(inputFile));
49+
50+
assert.strictEqual(
51+
console.log.getCall(0).args[0],
52+
2555
53+
);
54+
});
55+
56+
test('Test 4', function() {
57+
let inputFile = new File(__dirname + 'input/04 - test 4.txt');
58+
59+
execute(inputFile.readline.bind(inputFile));
60+
61+
assert.strictEqual(
62+
console.log.getCall(0).args[0],
63+
123456888
64+
);
65+
});
66+
67+
test('Test 5', function() {
68+
let inputFile = new File(__dirname + 'input/05 - test 5.txt');
69+
70+
execute(inputFile.readline.bind(inputFile));
71+
72+
assert.strictEqual(
73+
console.log.getCall(0).args[0],
74+
11123333333333333
75+
);
76+
});
77+
});
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
19
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
99
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
2533
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
123456879
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
11123159995399999

0 commit comments

Comments
 (0)