Skip to content

Commit 5115a4d

Browse files
committed
Adding tests for "1000000000D world".
1 parent 216e71e commit 5115a4d

File tree

10 files changed

+127
-0
lines changed

10 files changed

+127
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1111
- Tests for "Fax machine".
1212
- Tests for "Jack Silver: the casino".
1313
- Tests for "NGR basic radar".
14+
- Tests for "1000000000D world".
1415

1516
## [1.4.0] - 2022-03-03
1617
### Added
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
/**
2+
* The "1000000000D world" puzzle.
3+
*/
4+
function execute(readline) {
5+
const a = readline();
6+
const b = readline();
7+
8+
// Write an answer using console.log()
9+
// To debug: console.error('Debug messages...');
10+
11+
console.log('a DOT b');
12+
}
13+
14+
export { execute };
Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
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/community/training/easy/oneBillionDWorld/oneBillionDWorld.js';
6+
7+
/**
8+
* Tests for the "1000000000D world" puzzle.
9+
*/
10+
suite('1000000000D world', 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('Test 1', function() {
23+
let inputFile = new File('./test/community/training/easy/oneBillionDWorld/input/01 - test 1.txt');
24+
25+
execute(inputFile.readline.bind(inputFile));
26+
27+
assert.strictEqual(
28+
console.log.getCall(0).args[0],
29+
2
30+
);
31+
});
32+
33+
test('Test 2', function() {
34+
let inputFile = new File('./test/community/training/easy/oneBillionDWorld/input/02 - test 2.txt');
35+
36+
execute(inputFile.readline.bind(inputFile));
37+
38+
assert.strictEqual(
39+
console.log.getCall(0).args[0],
40+
17
41+
);
42+
});
43+
44+
test('Test 3', function() {
45+
let inputFile = new File('./test/community/training/easy/oneBillionDWorld/input/03 - test 3.txt');
46+
47+
execute(inputFile.readline.bind(inputFile));
48+
49+
assert.strictEqual(
50+
console.log.getCall(0).args[0],
51+
-1000000000
52+
);
53+
});
54+
55+
test('Test 4', function() {
56+
let inputFile = new File('./test/community/training/easy/oneBillionDWorld/input/04 - test 4.txt');
57+
58+
execute(inputFile.readline.bind(inputFile));
59+
60+
assert.strictEqual(
61+
console.log.getCall(0).args[0],
62+
-1999999395
63+
);
64+
});
65+
66+
test('Test 5', function() {
67+
let inputFile = new File('./test/community/training/easy/oneBillionDWorld/input/05 - test 5.txt');
68+
69+
execute(inputFile.readline.bind(inputFile));
70+
71+
assert.strictEqual(
72+
console.log.getCall(0).args[0],
73+
9221165894
74+
);
75+
});
76+
77+
test('Test 6', function() {
78+
let inputFile = new File('./test/community/training/easy/oneBillionDWorld/input/06 - test 6.txt');
79+
80+
execute(inputFile.readline.bind(inputFile));
81+
82+
assert.strictEqual(
83+
console.log.getCall(0).args[0],
84+
0
85+
);
86+
});
87+
88+
test('Test 7', function() {
89+
let inputFile = new File('./test/community/training/easy/oneBillionDWorld/input/07 - test 7.txt');
90+
91+
execute(inputFile.readline.bind(inputFile));
92+
93+
assert.strictEqual(
94+
console.log.getCall(0).args[0],
95+
-213982941
96+
);
97+
});
98+
});
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
500000001 1 499999999 -1
2+
1000000000 1
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
5 1 5 2 999999990 0
2+
3 1 3 2 3 1 999999991 0
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
1000000000 1
2+
1000000000 -1
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10 999999945 -1
2+
999999945 2 10 10 9 9 8 8 7 7 6 6 5 5 4 4 3 3 2 2 1 1
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
61293583 -5 60141391 -10 30705144 6 18209987 8 3623360 -5 3715666 4 18252771 -5 24739354 7 107410335 -1 18585831 1 37735014 9 4459884 -3 10163437 -6 67811650 10 49967223 3 29661998 1 34417955 8 5997538 -5 12037693 0 12536915 1 35929119 10 17059584 -4 10232854 7 13870276 6 3519983 6 55936984 7 72768589 2 29183804 -3 33351647 7 20893540 5 17190111 1 27370514 5 17869452 -3 1811597 10 31545217 -10
2+
29853135 2 7370169 0 9807376 -5 90278577 -7 27976028 -3 131519266 1 68154 -9 2173005 -9 40036660 5 63310669 9 25674306 -10 24212637 -3 29203142 2 79327039 2 18493184 -9 1854019 1 47335765 -5 38838995 10 49608857 1 13201908 3 85586590 4 30040431 -10 30620504 6 16642661 2 52716485 5 31264011 -5 22986427 -5
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
100000000 1 100000000 1 100000000 1 100000000 1 100000000 1 100000000 1 100000000 1 100000000 1 100000000 1 100000000 1
2+
100000000 1 100000000 -1 100000000 1 100000000 -1 100000000 1 100000000 -1 100000000 1 100000000 -1 100000000 1 100000000 -1
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
26751891 1 12423842 0 24697032 -1 75825948 0 16058842 -1 5056344 -1 14781040 -1 48256886 0 37330872 1 68962932 1 37555307 1 2970721 0 26201429 1 48967194 -1 17837665 0 74719356 -2 17461041 -2 20765736 0 15044838 1 6518283 -2 10432178 -2 15225674 -2 6160520 0 32060077 0 52545144 0 3848757 -2 91480452 -1 99032044 1 89501141 1 1526814 0
2+
40312847 1 84841395 -2 43849784 1 3228664 -1 98445257 -1 22318921 0 42672597 0 4577041 0 5240860 -2 31151717 1 30451395 -2 35469153 -2 25313187 -2 40128193 1 15893237 1 6369211 1 3672509 -1 22259551 0 25942846 -2 12180032 1 4202901 0 68816164 1 520373 -2 107835622 1 50661951 -2 67145499 0 88144650 -1 18354443 -1

0 commit comments

Comments
 (0)