|
| 1 | +<?php |
| 2 | + |
| 3 | +declare(strict_types=1); |
| 4 | + |
| 5 | +namespace CyrilVerloop\Codingame\Tests\Community\Training\Medium\FunWithSetTheory; |
| 6 | + |
| 7 | +use CyrilVerloop\Codingame\Tests\PuzzleTest; |
| 8 | +use CyrilVerloop\Codingame\Community\Training\Medium\FunWithSetTheory\FunWithSetTheory; |
| 9 | + |
| 10 | +/** |
| 11 | + * Tests for the "Fun with set theory" puzzle. |
| 12 | + * |
| 13 | + * @covers \CyrilVerloop\Codingame\Community\Training\Medium\FunWithSetTheory\FunWithSetTheory |
| 14 | + * @group funWithSetTheory |
| 15 | + * @medium |
| 16 | + */ |
| 17 | +final class CGTest extends PuzzleTest |
| 18 | +{ |
| 19 | + public function setUp(): void |
| 20 | + { |
| 21 | + $this->puzzle = new FunWithSetTheory(); |
| 22 | + } |
| 23 | + |
| 24 | + /** |
| 25 | + * Test that the code can be executed for "With braces". |
| 26 | + * |
| 27 | + * @group funWithSetTheory_withBraces |
| 28 | + */ |
| 29 | + public function testCanExecuteWithBraces(): void |
| 30 | + { |
| 31 | + $this->expectExecuteOutputAnswer( |
| 32 | + __DIR__ . '/input/01 - with braces.txt', |
| 33 | + "1 2 3" . PHP_EOL |
| 34 | + ); |
| 35 | + } |
| 36 | + |
| 37 | + /** |
| 38 | + * Test that the code can be executed for "With brackets". |
| 39 | + * |
| 40 | + * @group funWithSetTheory_withBrackets |
| 41 | + */ |
| 42 | + public function testCanExecuteWithBrackets(): void |
| 43 | + { |
| 44 | + $this->expectExecuteOutputAnswer( |
| 45 | + __DIR__ . '/input/02 - with brackets.txt', |
| 46 | + "4 5 6 7 8 9" . PHP_EOL |
| 47 | + ); |
| 48 | + } |
| 49 | + |
| 50 | + /** |
| 51 | + * Test that the code can be executed for "Simple union". |
| 52 | + * |
| 53 | + * @group funWithSetTheory_simpleUnion |
| 54 | + */ |
| 55 | + public function testCanExecuteSimpleUnion(): void |
| 56 | + { |
| 57 | + $this->expectExecuteOutputAnswer( |
| 58 | + __DIR__ . '/input/03 - simple union.txt', |
| 59 | + "0 1 2 3 4 5" . PHP_EOL |
| 60 | + ); |
| 61 | + } |
| 62 | + |
| 63 | + /** |
| 64 | + * Test that the code can be executed for "Multiple unions". |
| 65 | + * |
| 66 | + * @group funWithSetTheory_multipleUnions |
| 67 | + */ |
| 68 | + public function testCanExecuteMultipleUnions(): void |
| 69 | + { |
| 70 | + $this->expectExecuteOutputAnswer( |
| 71 | + __DIR__ . '/input/04 - multiple unions.txt', |
| 72 | + "-2 -1 0 1 2 3 4 5 10" . PHP_EOL |
| 73 | + ); |
| 74 | + } |
| 75 | + |
| 76 | + /** |
| 77 | + * Test that the code can be executed for "Simple intersection". |
| 78 | + * |
| 79 | + * @group funWithSetTheory_simpleIntersection |
| 80 | + */ |
| 81 | + public function testCanExecuteSimpleIntersection(): void |
| 82 | + { |
| 83 | + $this->expectExecuteOutputAnswer( |
| 84 | + __DIR__ . '/input/05 - simple intersection.txt', |
| 85 | + "4" . PHP_EOL |
| 86 | + ); |
| 87 | + } |
| 88 | + |
| 89 | + /** |
| 90 | + * Test that the code can be executed for "Multiple intersections". |
| 91 | + * |
| 92 | + * @group funWithSetTheory_multipleIntersections |
| 93 | + */ |
| 94 | + public function testCanExecuteMultipleIntersections(): void |
| 95 | + { |
| 96 | + $this->expectExecuteOutputAnswer( |
| 97 | + __DIR__ . '/input/06 - multiple intersections.txt', |
| 98 | + "EMPTY" . PHP_EOL |
| 99 | + ); |
| 100 | + } |
| 101 | + |
| 102 | + /** |
| 103 | + * Test that the code can be executed for "Simple difference". |
| 104 | + * |
| 105 | + * @group funWithSetTheory_simpleDifference |
| 106 | + */ |
| 107 | + public function testCanExecuteSimpleDifference(): void |
| 108 | + { |
| 109 | + $this->expectExecuteOutputAnswer( |
| 110 | + __DIR__ . '/input/07 - simple difference.txt', |
| 111 | + "1 3" . PHP_EOL |
| 112 | + ); |
| 113 | + } |
| 114 | + |
| 115 | + /** |
| 116 | + * Test that the code can be executed for "Multiple differences". |
| 117 | + * |
| 118 | + * @group funWithSetTheory_multipleDifferences |
| 119 | + */ |
| 120 | + public function testCanExecuteMultipleDifferences(): void |
| 121 | + { |
| 122 | + $this->expectExecuteOutputAnswer( |
| 123 | + __DIR__ . '/input/08 - multiple differences.txt', |
| 124 | + "5 6 7 8 10" . PHP_EOL |
| 125 | + ); |
| 126 | + } |
| 127 | + |
| 128 | + /** |
| 129 | + * Test that the code can be executed for "Braces and brackets". |
| 130 | + * |
| 131 | + * @group funWithSetTheory_bracesAndBrackets |
| 132 | + */ |
| 133 | + public function testCanExecuteBracesAndBrackets(): void |
| 134 | + { |
| 135 | + $this->expectExecuteOutputAnswer( |
| 136 | + __DIR__ . '/input/09 - braces and brackets.txt', |
| 137 | + "8 16 20 24" . PHP_EOL |
| 138 | + ); |
| 139 | + } |
| 140 | + |
| 141 | + /** |
| 142 | + * Test that the code can be executed for "Empty set". |
| 143 | + * |
| 144 | + * @group funWithSetTheory_emptySet |
| 145 | + */ |
| 146 | + public function testCanExecuteEmptySet(): void |
| 147 | + { |
| 148 | + $this->expectExecuteOutputAnswer( |
| 149 | + __DIR__ . '/input/10 - empty set.txt', |
| 150 | + "EMPTY" . PHP_EOL |
| 151 | + ); |
| 152 | + } |
| 153 | + |
| 154 | + /** |
| 155 | + * Test that the code can be executed for "Negative numbers". |
| 156 | + * |
| 157 | + * @group funWithSetTheory_negativeNumbers |
| 158 | + */ |
| 159 | + public function testCanExecuteNegativeNumbers(): void |
| 160 | + { |
| 161 | + $this->expectExecuteOutputAnswer( |
| 162 | + __DIR__ . '/input/11 - negative numbers.txt', |
| 163 | + "-5 -2 -1" . PHP_EOL |
| 164 | + ); |
| 165 | + } |
| 166 | + |
| 167 | + /** |
| 168 | + * Test that the code can be executed for "Orientation of brackets". |
| 169 | + * |
| 170 | + * @group funWithSetTheory_orientationOfBrackets |
| 171 | + */ |
| 172 | + public function testCanExecuteOrientationOfBrackets(): void |
| 173 | + { |
| 174 | + $this->expectExecuteOutputAnswer( |
| 175 | + __DIR__ . '/input/12 - orientation of brackets.txt', |
| 176 | + "0 1" . PHP_EOL |
| 177 | + ); |
| 178 | + } |
| 179 | + |
| 180 | + /** |
| 181 | + * Test that the code can be executed for "Simple parentheses". |
| 182 | + * |
| 183 | + * @group funWithSetTheory_simpleParentheses |
| 184 | + */ |
| 185 | + public function testCanExecuteSimpleParentheses(): void |
| 186 | + { |
| 187 | + $this->expectExecuteOutputAnswer( |
| 188 | + __DIR__ . '/input/13 - simple parentheses.txt', |
| 189 | + "40 41 46 47 48 49 50" . PHP_EOL |
| 190 | + ); |
| 191 | + } |
| 192 | + |
| 193 | + /** |
| 194 | + * Test that the code can be executed for "Nested parentheses". |
| 195 | + * |
| 196 | + * @group funWithSetTheory_nestedParentheses |
| 197 | + */ |
| 198 | + public function testCanExecuteNestedParentheses(): void |
| 199 | + { |
| 200 | + $this->expectExecuteOutputAnswer( |
| 201 | + __DIR__ . '/input/14 - nested parentheses.txt', |
| 202 | + "46 47 48 49 50" . PHP_EOL |
| 203 | + ); |
| 204 | + } |
| 205 | + |
| 206 | + /** |
| 207 | + * Test that the code can be executed for "Everything!". |
| 208 | + * |
| 209 | + * @group funWithSetTheory_everything |
| 210 | + */ |
| 211 | + public function testCanExecuteEverything(): void |
| 212 | + { |
| 213 | + $this->expectExecuteOutputAnswer( |
| 214 | + __DIR__ . '/input/15 - everything!.txt', |
| 215 | + "6 7 8 9" . PHP_EOL |
| 216 | + ); |
| 217 | + } |
| 218 | +} |
0 commit comments