|
| 1 | +<?php |
| 2 | + |
| 3 | +declare(strict_types=1); |
| 4 | + |
| 5 | +namespace CyrilVerloop\Codingame\Tests\Training\Medium\TheGift; |
| 6 | + |
| 7 | +use CyrilVerloop\Codingame\Tests\PuzzleTest; |
| 8 | +use CyrilVerloop\Codingame\Training\Medium\TheGift\TheGift; |
| 9 | + |
| 10 | +/** |
| 11 | + * Tests for the "The gift" puzzle. |
| 12 | + * |
| 13 | + * @covers \CyrilVerloop\Codingame\Training\Medium\TheGift\TheGift |
| 14 | + * @group theGift |
| 15 | + */ |
| 16 | +final class TheGiftTest extends PuzzleTest |
| 17 | +{ |
| 18 | + public function setUp(): void |
| 19 | + { |
| 20 | + $this->puzzle = new TheGift(); |
| 21 | + } |
| 22 | + |
| 23 | + /** |
| 24 | + * Test that the code can be executed for "Example 1". |
| 25 | + * |
| 26 | + * @group conwaySequence_example1 |
| 27 | + */ |
| 28 | + public function testCanExecuteExample1(): void |
| 29 | + { |
| 30 | + $this->expectExecuteOutputAnswer( |
| 31 | + __DIR__ . '/input/01 - example 1.txt', |
| 32 | + 'IMPOSSIBLE' . PHP_EOL |
| 33 | + ); |
| 34 | + } |
| 35 | + |
| 36 | + /** |
| 37 | + * Test that the code can be executed for "Example 2". |
| 38 | + * |
| 39 | + * @group conwaySequence_example2 |
| 40 | + */ |
| 41 | + public function testCanExecuteExample2(): void |
| 42 | + { |
| 43 | + $this->expectExecuteOutputAnswer( |
| 44 | + __DIR__ . '/input/02 - example 2.txt', |
| 45 | + file_get_contents(__DIR__ . '/output/02 - example 2.txt') |
| 46 | + ); |
| 47 | + } |
| 48 | + |
| 49 | + /** |
| 50 | + * Test that the code can be executed for "Example 3". |
| 51 | + * |
| 52 | + * @group conwaySequence_example3 |
| 53 | + */ |
| 54 | + public function testCanExecuteExample3(): void |
| 55 | + { |
| 56 | + $this->expectExecuteOutputAnswer( |
| 57 | + __DIR__ . '/input/03 - example 3.txt', |
| 58 | + file_get_contents(__DIR__ . '/output/03 - example 3.txt') |
| 59 | + ); |
| 60 | + } |
| 61 | + |
| 62 | + /** |
| 63 | + * Test that the code can be executed for "Impossible". |
| 64 | + * |
| 65 | + * @group conwaySequence_impossible |
| 66 | + */ |
| 67 | + public function testCanExecuteImpossible(): void |
| 68 | + { |
| 69 | + $this->expectExecuteOutputAnswer( |
| 70 | + __DIR__ . '/input/04 - impossible.txt', |
| 71 | + 'IMPOSSIBLE' . PHP_EOL |
| 72 | + ); |
| 73 | + } |
| 74 | + |
| 75 | + /** |
| 76 | + * Test that the code can be executed for "Sort". |
| 77 | + * |
| 78 | + * @group conwaySequence_sort |
| 79 | + */ |
| 80 | + public function testCanExecuteSort(): void |
| 81 | + { |
| 82 | + $this->expectExecuteOutputAnswer( |
| 83 | + __DIR__ . '/input/05 - sort.txt', |
| 84 | + file_get_contents(__DIR__ . '/output/05 - sort.txt') |
| 85 | + ); |
| 86 | + } |
| 87 | + |
| 88 | + /** |
| 89 | + * Test that the code can be executed for "Budget limit". |
| 90 | + * |
| 91 | + * @group conwaySequence_budgetLimit |
| 92 | + */ |
| 93 | + public function testCanExecuteBudgetLimit(): void |
| 94 | + { |
| 95 | + $this->expectExecuteOutputAnswer( |
| 96 | + __DIR__ . '/input/06 - budget Limit.txt', |
| 97 | + file_get_contents(__DIR__ . '/output/06 - budget Limit.txt') |
| 98 | + ); |
| 99 | + } |
| 100 | + |
| 101 | + /** |
| 102 | + * Test that the code can be executed for "Several solutions budget". |
| 103 | + * |
| 104 | + * @group conwaySequence_severalSolutionsBudget |
| 105 | + */ |
| 106 | + public function testCanExecuteSeveralSolutionsBudget(): void |
| 107 | + { |
| 108 | + $this->expectExecuteOutputAnswer( |
| 109 | + __DIR__ . '/input/07 - several solutions budget.txt', |
| 110 | + file_get_contents(__DIR__ . '/output/07 - several solutions budget.txt') |
| 111 | + ); |
| 112 | + } |
| 113 | + |
| 114 | + /** |
| 115 | + * Test that the code can be executed for "Several solution fast". |
| 116 | + * |
| 117 | + * @group conwaySequence_severalSolutionFast |
| 118 | + */ |
| 119 | + public function testCanExecuteSeveralSolutionFast(): void |
| 120 | + { |
| 121 | + $this->expectExecuteOutputAnswer( |
| 122 | + __DIR__ . '/input/08 - several solution fast.txt', |
| 123 | + file_get_contents(__DIR__ . '/output/08 - several solution fast.txt') |
| 124 | + ); |
| 125 | + } |
| 126 | + |
| 127 | + /** |
| 128 | + * Test that the code can be executed for "Big random". |
| 129 | + * |
| 130 | + * @group conwaySequence_bigRandom |
| 131 | + */ |
| 132 | + public function testCanExecuteBigRandom(): void |
| 133 | + { |
| 134 | + $this->expectExecuteOutputAnswer( |
| 135 | + __DIR__ . '/input/09 - big random.txt', |
| 136 | + file_get_contents(__DIR__ . '/output/09 - big random.txt') |
| 137 | + ); |
| 138 | + } |
| 139 | +} |
0 commit comments