Skip to content

Commit afa6e99

Browse files
committed
Adding tests for "Rock paper scissors lizard
spock".
1 parent 5d67ad2 commit afa6e99

13 files changed

+1324
-1
lines changed

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,11 @@ 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+
## [3.2.0] - 2022-02-18
88
### Added
99
- Tests for "Container terminal".
1010
- Tests for "Rectangle partition".
11+
- Tests for "Rock paper scissors lizard spock".
1112

1213
## [3.1.0] - 2022-02-17
1314
### Added
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace CyrilVerloop\Codingame\Community\Training\Easy\RockPaperScissorsLizardSpock;
6+
7+
use CyrilVerloop\Codingame\Puzzle;
8+
9+
/**
10+
* The "Rock paper scissors lizard spock" puzzle.
11+
*/
12+
class RockPaperScissorsLizardSpock implements Puzzle
13+
{
14+
public function execute($stdin): void
15+
{
16+
fscanf(STDIN, "%d", $N);
17+
for ($i = 0; $i < $N; $i++)
18+
{
19+
fscanf(STDIN, "%d %s", $NUMPLAYER, $SIGNPLAYER);
20+
}
21+
22+
// Write an answer using echo(). DON'T FORGET THE TRAILING \n
23+
24+
echo("WHO IS THE WINNER?\n");
25+
}
26+
}
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace CyrilVerloop\Codingame\Tests\Community\Training\Easy\RockPaperScissorsLizardSpock;
6+
7+
use CyrilVerloop\Codingame\Tests\PuzzleTest;
8+
use CyrilVerloop\Codingame\Community\Training\Easy\RockPaperScissorsLizardSpock\RockPaperScissorsLizardSpock;
9+
10+
/**
11+
* Tests for the "Rock paper scissors lizard spock" puzzle.
12+
*
13+
* @covers \CyrilVerloop\Codingame\Community\Training\Easy\RockPaperScissorsLizardSpock\RockPaperScissorsLizardSpock
14+
* @group rockPaperScissorsLizardSpock
15+
*/
16+
final class CGTest extends PuzzleTest
17+
{
18+
public function setUp(): void
19+
{
20+
$this->puzzle = new RockPaperScissorsLizardSpock();
21+
}
22+
23+
/**
24+
* Test that the code can be executed for "Test 1 - same as example".
25+
*
26+
* @group rockPaperScissorsLizardSpock_test1SameAsExample
27+
*/
28+
public function testCanExecuteTest1SameAsExample(): void
29+
{
30+
$this->expectExecuteOutputAnswer(
31+
__DIR__ . '/input/01 - test 1 - same as example.txt',
32+
file_get_contents(__DIR__ . '/output/01 - test 1 - same as example.txt')
33+
);
34+
}
35+
36+
/**
37+
* Test that the code can be executed for "Test 2 - with 2 players".
38+
*
39+
* @group rockPaperScissorsLizardSpock_test2With2Players
40+
*/
41+
public function testCanExecuteTest2With2Players(): void
42+
{
43+
$this->expectExecuteOutputAnswer(
44+
__DIR__ . '/input/02 - test 2 - with 2 players.txt',
45+
file_get_contents(__DIR__ . '/output/02 - test 2 - with 2 players.txt')
46+
);
47+
}
48+
49+
/**
50+
* Test that the code can be executed for "Test 3 - with 32 players".
51+
*
52+
* @group rockPaperScissorsLizardSpock_test3With32Players
53+
*/
54+
public function testCanExecuteTest3With32Players(): void
55+
{
56+
$this->expectExecuteOutputAnswer(
57+
__DIR__ . '/input/03 - test 3 - with 32 players.txt',
58+
file_get_contents(__DIR__ . '/output/03 - test 3 - with 32 players.txt')
59+
);
60+
}
61+
62+
/**
63+
* Test that the code can be executed for "Test 4 - only rock and paper".
64+
*
65+
* @group rockPaperScissorsLizardSpock_test4OnlyRockAndPaper
66+
*/
67+
public function testCanExecuteTest4OnlyRockAndPaper(): void
68+
{
69+
$this->expectExecuteOutputAnswer(
70+
__DIR__ . '/input/04 - test 4 - only rock and paper.txt',
71+
file_get_contents(__DIR__ . '/output/04 - test 4 - only rock and paper.txt')
72+
);
73+
}
74+
75+
/**
76+
* Test that the code can be executed for "Test 5 - with 1024 players".
77+
*
78+
* @group rockPaperScissorsLizardSpock_test5With1024Players
79+
*/
80+
public function testCanExecuteTest5With1024Players(): void
81+
{
82+
$this->expectExecuteOutputAnswer(
83+
__DIR__ . '/input/05 - test 5 - with 1024 players.txt',
84+
file_get_contents(__DIR__ . '/output/05 - test 5 - with 1024 players.txt')
85+
);
86+
}
87+
}
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)