Skip to content

Commit 826f6f1

Browse files
committed
Adding tests for "Rooks movements".
1 parent a4e4e3b commit 826f6f1

File tree

11 files changed

+133
-1
lines changed

11 files changed

+133
-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.5.0] - 2022-03-03
88
### Added
99
- Tests for "Blowing fuse".
1010
- Tests for "Container terminal".
@@ -16,6 +16,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1616
- Tests for "Rectangle partition".
1717
- Tests for "Robot show".
1818
- Tests for "Rock paper scissors lizard Spock".
19+
- Tests for "Rooks movements".
1920

2021
## [1.4.0] - 2022-03-03
2122
### Added
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/**
2+
* The "Rooks movements" puzzle.
3+
*/
4+
function execute(readline) {
5+
const rookPosition = readline();
6+
const nbPieces = parseInt(readline());
7+
for (let i = 0; i < nbPieces; i++) {
8+
var inputs = readline().split(' ');
9+
const colour = parseInt(inputs[0]);
10+
const onePiece = inputs[1];
11+
}
12+
13+
// Write an answer using console.log()
14+
// To debug: console.error('Debug messages...');
15+
16+
console.log('ANSWER');
17+
}
18+
19+
export { execute };
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
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/rooksMovements/rooksMovements.js';
6+
7+
/**
8+
* Tests for the "Rooks movements" puzzle.
9+
*/
10+
suite('Rooks movements', 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('MOVING FREELY', function() {
23+
let inputFile = new File('./test/community/training/easy/rooksMovements/input/01 - MOVING FREELY.txt');
24+
25+
execute(inputFile.readline.bind(inputFile));
26+
27+
assertOutputAnswer('./test/community/training/easy/rooksMovements/output/01 - MOVING FREELY.txt');
28+
});
29+
30+
test('CLOSE TO THE EDGE', function() {
31+
let inputFile = new File('./test/community/training/easy/rooksMovements/input/02 - CLOSE TO THE EDGE.txt');
32+
33+
execute(inputFile.readline.bind(inputFile));
34+
35+
assertOutputAnswer('./test/community/training/easy/rooksMovements/output/02 - CLOSE TO THE EDGE.txt');
36+
});
37+
38+
test('ONLY ALLIES', function() {
39+
let inputFile = new File('./test/community/training/easy/rooksMovements/input/03 - ONLY ALLIES.txt');
40+
41+
execute(inputFile.readline.bind(inputFile));
42+
43+
assertOutputAnswer('./test/community/training/easy/rooksMovements/output/03 - ONLY ALLIES.txt');
44+
});
45+
46+
test('FOR FRODOOO', function() {
47+
let inputFile = new File('./test/community/training/easy/rooksMovements/input/04 - FOR FRODOOO.txt');
48+
49+
execute(inputFile.readline.bind(inputFile));
50+
51+
assertOutputAnswer('./test/community/training/easy/rooksMovements/output/04 - FOR FRODOOO.txt');
52+
});
53+
});
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
d5
2+
2
3+
0 c1
4+
1 e8
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
a8
2+
5
3+
0 e8
4+
1 d7
5+
0 c6
6+
1 b5
7+
0 a4
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
d5
2+
2
3+
0 g5
4+
0 d2
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
d5
2+
3
3+
0 g5
4+
0 d2
5+
1 d7
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
Rd5-a5
2+
Rd5-b5
3+
Rd5-c5
4+
Rd5-d1
5+
Rd5-d2
6+
Rd5-d3
7+
Rd5-d4
8+
Rd5-d6
9+
Rd5-d7
10+
Rd5-d8
11+
Rd5-e5
12+
Rd5-f5
13+
Rd5-g5
14+
Rd5-h5
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
Ra8-a5
2+
Ra8-a6
3+
Ra8-a7
4+
Ra8-b8
5+
Ra8-c8
6+
Ra8-d8
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
Rd5-a5
2+
Rd5-b5
3+
Rd5-c5
4+
Rd5-d3
5+
Rd5-d4
6+
Rd5-d6
7+
Rd5-d7
8+
Rd5-d8
9+
Rd5-e5
10+
Rd5-f5
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
Rd5-a5
2+
Rd5-b5
3+
Rd5-c5
4+
Rd5-d3
5+
Rd5-d4
6+
Rd5-d6
7+
Rd5-e5
8+
Rd5-f5
9+
Rd5xd7

0 commit comments

Comments
 (0)