Skip to content

Commit 37c79a5

Browse files
committed
Adding tests for "Die handedness".
1 parent 25b0e1f commit 37c79a5

File tree

13 files changed

+211
-1
lines changed

13 files changed

+211
-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+
## [3.7.0] - 2022-03-31
88
### Added
99
- Tests for "Credit card verifier (Luhn’s algorithm)".
1010
- Tests for "Van Eck's sequence".
@@ -22,6 +22,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2222
- Tests for "Mountain map".
2323
- Tests for "Create the longest sequence of 1s".
2424
- Tests for "Reverse Minesweeper".
25+
- Tests for "Die handedness".
2526

2627
## [3.6.0] - 2022-03-11
2728
### 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\DieHandedness;
6+
7+
use CyrilVerloop\Codingame\Puzzle;
8+
9+
/**
10+
* The "Die handedness" puzzle.
11+
*/
12+
class DieHandedness implements Puzzle
13+
{
14+
public function execute($stdin): void
15+
{
16+
for ($i = 0; $i < 3; $i++)
17+
{
18+
$line = stream_get_line($stdin, 6 + 1, "\n");// One line out of three in the string describing the arrangement of the numbers.
19+
}
20+
21+
// Write an answer using echo(). DON'T FORGET THE TRAILING \n
22+
23+
// Output one of "right-handed", "left-handed" and "degenerate".
24+
echo("handedness\n");
25+
}
26+
}
Lines changed: 153 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,153 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace CyrilVerloop\Codingame\Tests\Community\Training\Easy\DieHandedness;
6+
7+
use CyrilVerloop\Codingame\Tests\PuzzleTest;
8+
use CyrilVerloop\Codingame\Community\Training\Easy\DieHandedness\DieHandedness;
9+
10+
/**
11+
* Tests for the "Die handedness" puzzle.
12+
*
13+
* @covers \CyrilVerloop\Codingame\Community\Training\Easy\DieHandedness\DieHandedness
14+
* @group dieHandedness
15+
* @medium
16+
*/
17+
final class CGTest extends PuzzleTest
18+
{
19+
public function setUp(): void
20+
{
21+
$this->puzzle = new DieHandedness();
22+
}
23+
24+
/**
25+
* Test that the code can be executed for "Test 1".
26+
*
27+
* @group dieHandedness_test1
28+
*/
29+
public function testCanExecuteTest1(): void
30+
{
31+
$this->expectExecuteOutputAnswer(
32+
__DIR__ . '/input/01 - test 1.txt',
33+
"right-handed" . PHP_EOL
34+
);
35+
}
36+
37+
/**
38+
* Test that the code can be executed for "Test 2".
39+
*
40+
* @group dieHandedness_test2
41+
*/
42+
public function testCanExecuteTest2(): void
43+
{
44+
$this->expectExecuteOutputAnswer(
45+
__DIR__ . '/input/02 - test 2.txt',
46+
"degenerate" . PHP_EOL
47+
);
48+
}
49+
50+
/**
51+
* Test that the code can be executed for "Test 3".
52+
*
53+
* @group dieHandedness_test3
54+
*/
55+
public function testCanExecuteTest3(): void
56+
{
57+
$this->expectExecuteOutputAnswer(
58+
__DIR__ . '/input/03 - test 3.txt',
59+
"left-handed" . PHP_EOL
60+
);
61+
}
62+
63+
/**
64+
* Test that the code can be executed for "Test 4".
65+
*
66+
* @group dieHandedness_test4
67+
*/
68+
public function testCanExecuteTest4(): void
69+
{
70+
$this->expectExecuteOutputAnswer(
71+
__DIR__ . '/input/04 - test 4.txt',
72+
"degenerate" . PHP_EOL
73+
);
74+
}
75+
76+
/**
77+
* Test that the code can be executed for "Test 5".
78+
*
79+
* @group dieHandedness_test5
80+
*/
81+
public function testCanExecuteTest5(): void
82+
{
83+
$this->expectExecuteOutputAnswer(
84+
__DIR__ . '/input/05 - test 5.txt',
85+
"right-handed" . PHP_EOL
86+
);
87+
}
88+
89+
/**
90+
* Test that the code can be executed for "Test 6".
91+
*
92+
* @group dieHandedness_test6
93+
*/
94+
public function testCanExecuteTest6(): void
95+
{
96+
$this->expectExecuteOutputAnswer(
97+
__DIR__ . '/input/06 - test 6.txt',
98+
"degenerate" . PHP_EOL
99+
);
100+
}
101+
102+
/**
103+
* Test that the code can be executed for "Test 7".
104+
*
105+
* @group dieHandedness_test7
106+
*/
107+
public function testCanExecuteTest7(): void
108+
{
109+
$this->expectExecuteOutputAnswer(
110+
__DIR__ . '/input/07 - test 7.txt',
111+
"left-handed" . PHP_EOL
112+
);
113+
}
114+
115+
/**
116+
* Test that the code can be executed for "Test 8".
117+
*
118+
* @group dieHandedness_test8
119+
*/
120+
public function testCanExecuteTest8(): void
121+
{
122+
$this->expectExecuteOutputAnswer(
123+
__DIR__ . '/input/08 - test 8.txt',
124+
"right-handed" . PHP_EOL
125+
);
126+
}
127+
128+
/**
129+
* Test that the code can be executed for "Test 9".
130+
*
131+
* @group dieHandedness_test9
132+
*/
133+
public function testCanExecuteTest9(): void
134+
{
135+
$this->expectExecuteOutputAnswer(
136+
__DIR__ . '/input/09 - test 9.txt',
137+
"degenerate" . PHP_EOL
138+
);
139+
}
140+
141+
/**
142+
* Test that the code can be executed for "Test 10".
143+
*
144+
* @group dieHandedness_test10
145+
*/
146+
public function testCanExecuteTest10(): void
147+
{
148+
$this->expectExecuteOutputAnswer(
149+
__DIR__ . '/input/10 - test 10.txt',
150+
"degenerate" . PHP_EOL
151+
);
152+
}
153+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
1
2+
2354
3+
6
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
1
2+
4256
3+
3
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
4
2+
6512
3+
3
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
4
2+
5612
3+
3
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
4
2+
1562
3+
3
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
3
2+
2561
3+
4
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
3
2+
2156
3+
4

0 commit comments

Comments
 (0)