Skip to content

Commit a4e4e3b

Browse files
committed
Adding tests for "Rock paper scissors lizard Spock".
1 parent f2e9382 commit a4e4e3b

13 files changed

+1289
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1515
- Tests for "1D bush fire".
1616
- Tests for "Rectangle partition".
1717
- Tests for "Robot show".
18+
- Tests for "Rock paper scissors lizard Spock".
1819

1920
## [1.4.0] - 2022-03-03
2021
### Added
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/**
2+
* The "Rock paper scissors lizard Spock" puzzle.
3+
*/
4+
function execute(readline) {
5+
const N = parseInt(readline());
6+
for (let i = 0; i < N; i++) {
7+
var inputs = readline().split(' ');
8+
const NUMPLAYER = parseInt(inputs[0]);
9+
const SIGNPLAYER = inputs[1];
10+
}
11+
12+
// Write an answer using console.log()
13+
// To debug: console.error('Debug messages...');
14+
15+
console.log('WHO IS THE WINNER?');
16+
}
17+
18+
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/rockPaperScissorsLizardSpock/rockPaperScissorsLizardSpock.js';
6+
7+
/**
8+
* Tests for the "Rock paper scissors lizard Spock" puzzle.
9+
*/
10+
suite('Rock paper scissors lizard Spock', 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 - Same as example', function() {
23+
let inputFile = new File('./test/community/training/easy/rockPaperScissorsLizardSpock/input/01 - test 1 - same as example.txt');
24+
25+
execute(inputFile.readline.bind(inputFile));
26+
27+
assertOutputAnswer('./test/community/training/easy/rockPaperScissorsLizardSpock/output/01 - test 1 - same as example.txt');
28+
});
29+
30+
test('Test 2 - With 2 players', function() {
31+
let inputFile = new File('./test/community/training/easy/rockPaperScissorsLizardSpock/input/02 - test 2 - with 2 players.txt');
32+
33+
execute(inputFile.readline.bind(inputFile));
34+
35+
assertOutputAnswer('./test/community/training/easy/rockPaperScissorsLizardSpock/output/02 - test 2 - with 2 players.txt');
36+
});
37+
38+
test('Test 3 - With 32 players', function() {
39+
let inputFile = new File('./test/community/training/easy/rockPaperScissorsLizardSpock/input/03 - test 3 - with 32 players.txt');
40+
41+
execute(inputFile.readline.bind(inputFile));
42+
43+
assertOutputAnswer('./test/community/training/easy/rockPaperScissorsLizardSpock/output/03 - test 3 - with 32 players.txt');
44+
});
45+
46+
test('Test 4 - Only Rock and Paper', function() {
47+
let inputFile = new File('./test/community/training/easy/rockPaperScissorsLizardSpock/input/04 - test 4 - only rock and paper.txt');
48+
49+
execute(inputFile.readline.bind(inputFile));
50+
51+
assertOutputAnswer('./test/community/training/easy/rockPaperScissorsLizardSpock/output/04 - test 4 - only rock and paper.txt');
52+
});
53+
54+
test('Test 5 - With 1024 players', function() {
55+
let inputFile = new File('./test/community/training/easy/rockPaperScissorsLizardSpock/input/05 - test 5 - with 1024 players.txt');
56+
57+
execute(inputFile.readline.bind(inputFile));
58+
59+
assertOutputAnswer('./test/community/training/easy/rockPaperScissorsLizardSpock/output/05 - test 5 - with 1024 players.txt');
60+
});
61+
});
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
8
2+
4 R
3+
1 P
4+
8 P
5+
3 R
6+
7 C
7+
5 S
8+
6 L
9+
2 L
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
2
2+
1 S
3+
2 S
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
32
2+
28 R
3+
3 R
4+
13 L
5+
6 P
6+
32 C
7+
5 R
8+
11 S
9+
27 S
10+
22 L
11+
31 R
12+
30 R
13+
10 P
14+
18 R
15+
23 R
16+
8 R
17+
20 S
18+
7 P
19+
19 P
20+
26 P
21+
4 R
22+
16 C
23+
21 P
24+
1 C
25+
14 C
26+
29 R
27+
9 P
28+
25 C
29+
24 P
30+
15 R
31+
2 L
32+
12 L
33+
17 S
Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
128
2+
35 R
3+
66 R
4+
68 R
5+
81 R
6+
27 R
7+
88 R
8+
74 R
9+
125 R
10+
116 R
11+
9 R
12+
115 R
13+
4 R
14+
52 R
15+
111 R
16+
103 R
17+
77 R
18+
114 R
19+
71 R
20+
113 R
21+
100 R
22+
112 R
23+
3 R
24+
85 R
25+
57 R
26+
13 R
27+
60 R
28+
47 R
29+
31 R
30+
122 R
31+
50 R
32+
44 R
33+
106 R
34+
86 R
35+
65 R
36+
22 R
37+
37 R
38+
26 R
39+
43 R
40+
55 R
41+
42 R
42+
23 R
43+
45 R
44+
89 R
45+
91 R
46+
28 R
47+
63 R
48+
18 R
49+
67 R
50+
34 R
51+
127 R
52+
107 R
53+
41 R
54+
36 R
55+
61 R
56+
97 R
57+
87 R
58+
118 R
59+
110 R
60+
96 R
61+
40 R
62+
14 R
63+
102 R
64+
84 R
65+
126 R
66+
117 R
67+
83 R
68+
101 R
69+
80 R
70+
58 R
71+
82 R
72+
119 R
73+
72 R
74+
51 R
75+
21 R
76+
33 R
77+
8 R
78+
1 R
79+
7 R
80+
92 R
81+
25 R
82+
16 R
83+
30 R
84+
79 R
85+
46 R
86+
94 R
87+
120 R
88+
59 R
89+
121 R
90+
108 R
91+
69 R
92+
73 R
93+
124 R
94+
12 R
95+
93 R
96+
78 R
97+
5 R
98+
29 R
99+
70 R
100+
109 R
101+
48 R
102+
64 R
103+
76 R
104+
38 R
105+
104 R
106+
75 R
107+
128 P
108+
20 R
109+
2 R
110+
95 R
111+
62 R
112+
10 R
113+
56 R
114+
99 R
115+
39 R
116+
105 R
117+
19 R
118+
15 R
119+
17 R
120+
54 R
121+
90 R
122+
6 R
123+
98 R
124+
123 R
125+
49 R
126+
32 R
127+
11 R
128+
53 R
129+
24 R

0 commit comments

Comments
 (0)