Skip to content

Commit fe5557c

Browse files
committed
Adding tests for "ASCII Art".
1 parent ab7de1f commit fe5557c

15 files changed

+178
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
88
### Added
99
- Base files to the project.
1010
- Tests for "Unary".
11+
- Tests for "ASCII Art".
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/**
2+
* The "ASCII Art" puzzle.
3+
*/
4+
function execute(readline) {
5+
const L = parseInt(readline());
6+
const H = parseInt(readline());
7+
const T = readline();
8+
for (let i = 0; i < H; i++) {
9+
const ROW = readline();
10+
}
11+
12+
// Write an answer using console.log()
13+
// To debug: console.error('Debug messages...');
14+
15+
console.log('answer');
16+
}
17+
18+
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/easy/ASCIIArt/ASCIIArt.js';
6+
7+
/**
8+
* Tests for the "ASCII Art" puzzle.
9+
*/
10+
suite('ASCII art', 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('can execute "Test only one letter E"', function() {
23+
let inputFile = new File('./test/training/easy/ASCIIArt/input/01 - test only one letter E.txt');
24+
25+
execute(inputFile.readline.bind(inputFile));
26+
27+
assertOutputAnswer('./test/training/easy/ASCIIArt/output/01 - test only one letter E.txt');
28+
});
29+
30+
test('can execute "Test MANHATTAN"', function() {
31+
let inputFile = new File('./test/training/easy/ASCIIArt/input/02 - test MANHATTAN.txt');
32+
33+
execute(inputFile.readline.bind(inputFile));
34+
35+
assertOutputAnswer('./test/training/easy/ASCIIArt/output/02 - test MANHATTAN.txt');
36+
});
37+
38+
test('can execute "Test ManhAtTan"', function() {
39+
let inputFile = new File('./test/training/easy/ASCIIArt/input/03 - test ManhAtTan.txt');
40+
41+
execute(inputFile.readline.bind(inputFile));
42+
43+
assertOutputAnswer('./test/training/easy/ASCIIArt/output/03 - test ManhAtTan.txt');
44+
});
45+
46+
test('can execute "Test M@NH@TT@N"', function() {
47+
let inputFile = new File('./test/training/easy/ASCIIArt/input/04 - test M@NH@TT@N.txt');
48+
49+
execute(inputFile.readline.bind(inputFile));
50+
51+
assertOutputAnswer('./test/training/easy/ASCIIArt/output/04 - test M@NH@TT@N.txt');
52+
});
53+
54+
test('can execute "MANHATTAN with another ASCII representation"', function() {
55+
let inputFile = new File('./test/training/easy/ASCIIArt/input/05 - MANHATTAN with another ASCII representation.txt');
56+
57+
execute(inputFile.readline.bind(inputFile));
58+
59+
assertOutputAnswer('./test/training/easy/ASCIIArt/output/05 - MANHATTAN with another ASCII representation.txt');
60+
});
61+
62+
test('can execute "Test MAN HAT TAN"', function() {
63+
let inputFile = new File('./test/training/easy/ASCIIArt/input/06 - test MAN HAT TAN.txt');
64+
65+
execute(inputFile.readline.bind(inputFile));
66+
67+
assertOutputAnswer('./test/training/easy/ASCIIArt/output/06 - test MAN HAT TAN.txt');
68+
});
69+
});
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
4
2+
5
3+
E
4+
# ## ## ## ### ### ## # # ### ## # # # # # ### # ## # ## ## ### # # # # # # # # # # ### ###
5+
# # # # # # # # # # # # # # # # # ### # # # # # # # # # # # # # # # # # # # # # # # #
6+
### ## # # # ## ## # # ### # # ## # ### # # # # ## # # ## # # # # # # ### # # # ##
7+
# # # # # # # # # # # # # # # # # # # # # # # # # # ## # # # # # # # # ### # # # #
8+
# # ## ## ## ### # ## # # ### # # # ### # # # # # # # # # ## # ### # # # # # # ### #
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
4
2+
5
3+
MANHATTAN
4+
# ## ## ## ### ### ## # # ### ## # # # # # ### # ## # ## ## ### # # # # # # # # # # ### ###
5+
# # # # # # # # # # # # # # # # # ### # # # # # # # # # # # # # # # # # # # # # # # #
6+
### ## # # # ## ## # # ### # # ## # ### # # # # ## # # ## # # # # # # ### # # # ##
7+
# # # # # # # # # # # # # # # # # # # # # # # # # # ## # # # # # # # # ### # # # #
8+
# # ## ## ## ### # ## # # ### # # # ### # # # # # # # # # ## # ### # # # # # # ### #
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
4
2+
5
3+
ManhAtTan
4+
# ## ## ## ### ### ## # # ### ## # # # # # ### # ## # ## ## ### # # # # # # # # # # ### ###
5+
# # # # # # # # # # # # # # # # # ### # # # # # # # # # # # # # # # # # # # # # # # #
6+
### ## # # # ## ## # # ### # # ## # ### # # # # ## # # ## # # # # # # ### # # # ##
7+
# # # # # # # # # # # # # # # # # # # # # # # # # # ## # # # # # # # # ### # # # #
8+
# # ## ## ## ### # ## # # ### # # # ### # # # # # # # # # ## # ### # # # # # # ### #
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
4
2+
5
3+
M@NH@TT@N
4+
# ## ## ## ### ### ## # # ### ## # # # # # ### # ## # ## ## ### # # # # # # # # # # ### ###
5+
# # # # # # # # # # # # # # # # # ### # # # # # # # # # # # # # # # # # # # # # # # #
6+
### ## # # # ## ## # # ### # # ## # ### # # # # ## # # ## # # # # # # ### # # # ##
7+
# # # # # # # # # # # # # # # # # # # # # # # # # # ## # # # # # # # # ### # # # #
8+
# # ## ## ## ### # ## # # ### # # # ### # # # # # # # # # ## # ### # # # # # # ### #
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
20
2+
11
3+
MANHATTAN
4+
.----------------. .----------------. .----------------. .----------------. .----------------. .----------------. .----------------. .----------------. .----------------. .----------------. .----------------. .----------------. .----------------. .-----------------. .----------------. .----------------. .----------------. .----------------. .----------------. .----------------. .----------------. .----------------. .----------------. .----------------. .----------------. .----------------. .----------------.
5+
| .--------------. || .--------------. || .--------------. || .--------------. || .--------------. || .--------------. || .--------------. || .--------------. || .--------------. || .--------------. || .--------------. || .--------------. || .--------------. || .--------------. || .--------------. || .--------------. || .--------------. || .--------------. || .--------------. || .--------------. || .--------------. || .--------------. || .--------------. || .--------------. || .--------------. || .--------------. || .--------------. |
6+
| | __ | || | ______ | || | ______ | || | ________ | || | _________ | || | _________ | || | ______ | || | ____ ____ | || | _____ | || | _____ | || | ___ ____ | || | _____ | || | ____ ____ | || | ____ _____ | || | ____ | || | ______ | || | ___ | || | _______ | || | _______ | || | _________ | || | _____ _____ | || | ____ ____ | || | _____ _____ | || | ____ ____ | || | ____ ____ | || | ________ | || | ______ | |
7+
| | / \ | || | |_ _ \ | || | .' ___ | | || | |_ ___ `. | || | |_ ___ | | || | |_ ___ | | || | .' ___ | | || | |_ || _| | || | |_ _| | || | |_ _| | || | |_ ||_ _| | || | |_ _| | || ||_ \ / _|| || ||_ \|_ _| | || | .' `. | || | |_ __ \ | || | .' '. | || | |_ __ \ | || | / ___ | | || | | _ _ | | || ||_ _||_ _|| || ||_ _| |_ _| | || ||_ _||_ _|| || | |_ _||_ _| | || | |_ _||_ _| | || | | __ _| | || | / _ __ `. | |
8+
| | / /\ \ | || | | |_) | | || | / .' \_| | || | | | `. \ | || | | |_ \_| | || | | |_ \_| | || | / .' \_| | || | | |__| | | || | | | | || | | | | || | | |_/ / | || | | | | || | | \/ | | || | | \ | | | || | / .--. \ | || | | |__) | | || | / .-. \ | || | | |__) | | || | | (__ \_| | || | |_/ | | \_| | || | | | | | | || | \ \ / / | || | | | /\ | | | || | \ \ / / | || | \ \ / / | || | |_/ / / | || | |_/____) | | |
9+
| | / ____ \ | || | | __'. | || | | | | || | | | | | | || | | _| _ | || | | _| | || | | | ____ | || | | __ | | || | | | | || | _ | | | || | | __'. | || | | | _ | || | | |\ /| | | || | | |\ \| | | || | | | | | | || | | ___/ | || | | | | | | || | | __ / | || | '.___`-. | || | | | | || | | ' ' | | || | \ \ / / | || | | |/ \| | | || | > `' < | || | \ \/ / | || | .'.' _ | || | / ___.' | |
10+
| | _/ / \ \_ | || | _| |__) | | || | \ `.___.'\ | || | _| |___.' / | || | _| |___/ | | || | _| |_ | || | \ `.___] _| | || | _| | | |_ | || | _| |_ | || | | |_' | | || | _| | \ \_ | || | _| |__/ | | || | _| |_\/_| |_ | || | _| |_\ |_ | || | \ `--' / | || | _| |_ | || | \ `-' \_ | || | _| | \ \_ | || | |`\____) | | || | _| |_ | || | \ `--' / | || | \ ' / | || | | /\ | | || | _/ /'`\ \_ | || | _| |_ | || | _/ /__/ | | || | |_| | |
11+
| ||____| |____|| || | |_______/ | || | `._____.' | || | |________.' | || | |_________| | || | |_____| | || | `._____.' | || | |____||____| | || | |_____| | || | `.___.' | || | |____||____| | || | |________| | || ||_____||_____|| || ||_____|\____| | || | `.____.' | || | |_____| | || | `.___.\__| | || | |____| |___| | || | |_______.' | || | |_____| | || | `.__.' | || | \_/ | || | |__/ \__| | || | |____||____| | || | |______| | || | |________| | || | (_) | |
12+
| | | || | | || | | || | | || | | || | | || | | || | | || | | || | | || | | || | | || | | || | | || | | || | | || | | || | | || | | || | | || | | || | | || | | || | | || | | || | | || | | |
13+
| '--------------' || '--------------' || '--------------' || '--------------' || '--------------' || '--------------' || '--------------' || '--------------' || '--------------' || '--------------' || '--------------' || '--------------' || '--------------' || '--------------' || '--------------' || '--------------' || '--------------' || '--------------' || '--------------' || '--------------' || '--------------' || '--------------' || '--------------' || '--------------' || '--------------' || '--------------' || '--------------' |
14+
'----------------' '----------------' '----------------' '----------------' '----------------' '----------------' '----------------' '----------------' '----------------' '----------------' '----------------' '----------------' '----------------' '----------------' '----------------' '----------------' '----------------' '----------------' '----------------' '----------------' '----------------' '----------------' '----------------' '----------------' '----------------' '----------------' '----------------'
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
4
2+
5
3+
MAN HAT TAN
4+
# ## ## ## ### ### ## # # ### ## # # # # # ### # ## # ## ## ### # # # # # # # # # # ### ###
5+
# # # # # # # # # # # # # # # # # ### # # # # # # # # # # # # # # # # # # # # # # # #
6+
### ## # # # ## ## # # ### # # ## # ### # # # # ## # # ## # # # # # # ### # # # ##
7+
# # # # # # # # # # # # # # # # # # # # # # # # # # ## # # # # # # # # ### # # # #
8+
# # ## ## ## ### # ## # # ### # # # ### # # # # # # # # # ## # ### # # # # # # ### #
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
###
2+
#
3+
##
4+
#
5+
###

0 commit comments

Comments
 (0)