Skip to content

Commit d06ca29

Browse files
committed
Adding tests for "Bulk email generator".
1 parent e4f103b commit d06ca29

File tree

13 files changed

+169
-0
lines changed

13 files changed

+169
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
3131
- Tests for "Simple awalé".
3232
- Tests for "Simple load balancing".
3333
- Tests for "Are the clumps normal".
34+
- Tests for "Bulk email generator".
3435

3536
## [3.8.0] - 2022-04-30
3637
### Added
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace CyrilVerloop\Codingame\Community\Training\Easy\BulkEmailGenerator;
6+
7+
use CyrilVerloop\Codingame\Puzzle;
8+
9+
/**
10+
* The "Bulk email generator" puzzle.
11+
* @link https://www.codingame.com/ide/puzzle/bulk-email-generator
12+
*/
13+
class BulkEmailGenerator implements Puzzle
14+
{
15+
public function execute($stdin): void
16+
{
17+
fscanf($stdin, "%d", $N);
18+
for ($i = 0; $i < $N; $i++)
19+
{
20+
$line = stream_get_line($stdin, 10000 + 1, "\n");
21+
}
22+
23+
// Write an answer using echo(). DON'T FORGET THE TRAILING \n
24+
25+
echo("42\n");
26+
}
27+
}
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace CyrilVerloop\Codingame\Tests\Community\Training\Easy\BulkEmailGenerator;
6+
7+
use CyrilVerloop\Codingame\Tests\PuzzleTest;
8+
use CyrilVerloop\Codingame\Community\Training\Easy\BulkEmailGenerator\BulkEmailGenerator;
9+
10+
/**
11+
* Tests for the "Bulk email generator" puzzle.
12+
*
13+
* @covers \CyrilVerloop\Codingame\Community\Training\Easy\BulkEmailGenerator\BulkEmailGenerator
14+
* @group bulkEmailGenerator
15+
* @medium
16+
*/
17+
final class CGTest extends PuzzleTest
18+
{
19+
public function setUp(): void
20+
{
21+
$this->puzzle = new BulkEmailGenerator();
22+
}
23+
24+
/**
25+
* Test that the code can be executed for "Example".
26+
*
27+
* @group bulkEmailGenerator_example
28+
*/
29+
public function testCanExecuteExample(): void
30+
{
31+
$this->expectExecuteOutputAnswer(
32+
__DIR__ . '/input/01 - example.txt',
33+
file_get_contents(__DIR__ . '/output/01 - example.txt')
34+
);
35+
}
36+
37+
/**
38+
* Test that the code can be executed for "CG email".
39+
*
40+
* @group bulkEmailGenerator_CGEmail
41+
*/
42+
public function testCanExecuteCGEmail(): void
43+
{
44+
$this->expectExecuteOutputAnswer(
45+
__DIR__ . '/input/02 - CG email.txt',
46+
file_get_contents(__DIR__ . '/output/02 - CG email.txt')
47+
);
48+
}
49+
50+
/**
51+
* Test that the code can be executed for "Edge cases".
52+
*
53+
* @group bulkEmailGenerator_edgeCases
54+
*/
55+
public function testCanExecuteEdgeCases(): void
56+
{
57+
$this->expectExecuteOutputAnswer(
58+
__DIR__ . '/input/03 - edge cases.txt',
59+
file_get_contents(__DIR__ . '/output/03 - edge cases.txt')
60+
);
61+
}
62+
63+
/**
64+
* Test that the code can be executed for "Comment spam".
65+
*
66+
* @group bulkEmailGenerator_commentSpam
67+
*/
68+
public function testCanExecuteCommentSpam(): void
69+
{
70+
$this->expectExecuteOutputAnswer(
71+
__DIR__ . '/input/04 - comment spam.txt',
72+
file_get_contents(__DIR__ . '/output/04 - comment spam.txt')
73+
);
74+
}
75+
76+
/**
77+
* Test that the code can be executed for "More edge cases".
78+
*
79+
* @group bulkEmailGenerator_moreEdgeCases
80+
*/
81+
public function testCanExecuteMoreEdgeCases(): void
82+
{
83+
$this->expectExecuteOutputAnswer(
84+
__DIR__ . '/input/05 - more edge cases.txt',
85+
file_get_contents(__DIR__ . '/output/05 - more edge cases.txt')
86+
);
87+
}
88+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
3
2+
This is the (first|second|third) choice.
3+
This is the (first|second|third) choice.
4+
This is the (first|second|third) choice.
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
7
2+
(Hello|Hi|Bonjour|Salut|Hey) (les amis|coders|bande de @$%*),
3+
4+
I keep getting an error( 492|) in the notification area.
5+
Are you aware of that?
6+
7+
(Bye|Ciao|Fsck off|Best regards),
8+
Your Name Here
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
7
2+
(No choice)
3+
(Empty choice|)
4+
Lotsa (1|2|3|4|5|6|7|8|9|10|11|12|13|14|15|16|17|18|19|20|21|22|23|24|25|26|27|28|29|30|31|32|33|34|35|36|37|38|39|40|41|42|43|44|45|46|47|48|49|50|51|52|53|54|55|56|57|58|59|60|61|62|63|64|65|66|67|68|69|70|71|72|73|74|75|76|77|78|79|80|81|82|83|84|85|86|87|88|89|90|91|92|93|94|95|96|97|98|99|100) choices
5+
Does it (wrap|unwrap)?
6+
(Multi
7+
line|Multi
8+
line)
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
1
2+
(You must|You need to|You have to|You should) (take advantage of|make the most of|benefit from|take full advantage of) (all the|all of the|each of the|every one of the) software advancements that (happen to be|are actually|are|are generally) (a successful|an effective|an excellent|a prosperous) (Internet marketer|Online marketer|Internet entrepreneur|Affiliate marketer). (If your|In case your|Should your|When your) work (begins to|starts to|actually starts to) suffer, (the competition|your competition|competition|your competitors) could (leave you|make you|create) (in the|within the|inside the|from the) dust. Show (that you are|that you will be|that you are currently|you are) always (on the|around the|in the|about the) (cutting edge|innovative|leading edge|really advanced), (and they will|and they can) (learn to|learn how to|figure out how to|discover how to) trust (you and your|both you and your|you and the|your) products.
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
7
2+
(|Empty choice)
3+
(No choice)
4+
Lotsa (1|2|3|4|5|6|7|8|9|10|11|12|13|14|15|16|17|18|19|20|21|22|23|24|25|26|27|28|29|30|31|32|33|34|35|36|37|38|39|40|41|42|43|44|45|46|47|48|49|50|51|52|53|54|55|56|57|58|59|60|61|62|63|64|65|66|67|68|69|70|71|72|73|74|75|76|77|78|79|80|81|82|83|84|85|86|87|88|89|90|91|92|93|94|95|96|97|98|99|100) choices
5+
Does it (curve|blend)?
6+
(Lines
7+
by two|Two
8+
lines)
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
This is the first choice.
2+
This is the second choice.
3+
This is the third choice.
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
Hello coders,
2+
3+
I keep getting an error 492 in the notification area.
4+
Are you aware of that?
5+
6+
Best regards,
7+
Your Name Here

0 commit comments

Comments
 (0)