Skip to content

Commit 41f900d

Browse files
committed
Adding tests for "Fax machine".
1 parent c60c632 commit 41f900d

File tree

13 files changed

+126
-0
lines changed

13 files changed

+126
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
88
### Added
99
- Tests for "Blowing fuse".
1010
- Tests for "Container terminal".
11+
- Tests for "Fax machine".
1112

1213
## [1.4.0] - 2022-03-03
1314
### Added
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/**
2+
* The "Fax machine" puzzle.
3+
*/
4+
function execute(readline) {
5+
const W = parseInt(readline());
6+
const H = parseInt(readline());
7+
const T = readline();
8+
9+
// Write an answer using console.log()
10+
// To debug: console.error('Debug messages...');
11+
12+
console.log('|********|');
13+
console.log('|** |');
14+
console.log('| ****|');
15+
}
16+
17+
export { execute };
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
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/faxMachine/faxMachine.js';
6+
7+
/**
8+
* Tests for the "Fax machine" puzzle.
9+
*/
10+
suite('Fax machine', 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('The Example', function() {
23+
let inputFile = new File('./test/community/training/easy/faxMachine/input/01 - the example.txt');
24+
25+
execute(inputFile.readline.bind(inputFile));
26+
27+
assertOutputAnswer('./test/community/training/easy/faxMachine/output/01 - the example.txt');
28+
});
29+
30+
test('Half Black half white', function() {
31+
let inputFile = new File('./test/community/training/easy/faxMachine/input/02 - half black half white.txt');
32+
33+
execute(inputFile.readline.bind(inputFile));
34+
35+
assertOutputAnswer('./test/community/training/easy/faxMachine/output/02 - half black half white.txt');
36+
});
37+
38+
test('Hello', function() {
39+
let inputFile = new File('./test/community/training/easy/faxMachine/input/03 - hello.txt');
40+
41+
execute(inputFile.readline.bind(inputFile));
42+
43+
assertOutputAnswer('./test/community/training/easy/faxMachine/output/03 - hello.txt');
44+
});
45+
46+
test('Heart', function() {
47+
let inputFile = new File('./test/community/training/easy/faxMachine/input/04 - heart.txt');
48+
49+
execute(inputFile.readline.bind(inputFile));
50+
51+
assertOutputAnswer('./test/community/training/easy/faxMachine/output/04 - heart.txt');
52+
});
53+
54+
test('Inverse', function() {
55+
let inputFile = new File('./test/community/training/easy/faxMachine/input/05 - inverse.txt');
56+
57+
execute(inputFile.readline.bind(inputFile));
58+
59+
assertOutputAnswer('./test/community/training/easy/faxMachine/output/05 - inverse.txt');
60+
});
61+
});
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
8
2+
3
3+
10 10 4
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
32
2+
6
3+
93 99
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
16
2+
9
3+
16 18 2 2 2 3 2 5 2 2 2 10 6 3 2 5 2 2 2 3 2 5 2 2 2 3 2 19 16
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
23
2+
7
3+
6 4 3 4 11 6 1 6 11 11 13 9 16 6 18 4 20 2 10
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
23
2+
7
3+
0 6 4 3 4 11 6 1 6 11 11 13 9 16 6 18 4 20 2 10
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
|********|
2+
|** |
3+
| ****|
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
|********************************|
2+
|********************************|
3+
|***************************** |
4+
| |
5+
| |
6+
| |

0 commit comments

Comments
 (0)