|
| 1 | +<?php |
| 2 | + |
| 3 | +declare(strict_types=1); |
| 4 | + |
| 5 | +namespace CyrilVerloop\Codingame\Tests\Training\Hard\Surface; |
| 6 | + |
| 7 | +use CyrilVerloop\Codingame\Tests\PuzzleTest; |
| 8 | +use CyrilVerloop\Codingame\Training\Hard\Surface\Surface; |
| 9 | + |
| 10 | +/** |
| 11 | + * Tests for the "Surface" puzzle. |
| 12 | + * |
| 13 | + * @covers \CyrilVerloop\Codingame\Training\Hard\Surface\Surface |
| 14 | + * @group surface |
| 15 | + */ |
| 16 | +final class SurfaceTest extends PuzzleTest |
| 17 | +{ |
| 18 | + public function setUp(): void |
| 19 | + { |
| 20 | + $this->puzzle = new Surface(); |
| 21 | + } |
| 22 | + |
| 23 | + /** |
| 24 | + * Test that the code can be executed for "Example of the statement". |
| 25 | + * |
| 26 | + * @group surface_exampleOfTheStatement |
| 27 | + */ |
| 28 | + public function testCanExecuteExampleOfTheStatement(): void |
| 29 | + { |
| 30 | + $this->expectExecuteOutputAnswer( |
| 31 | + __DIR__ . '/input/01 - example of the statement.txt', |
| 32 | + file_get_contents(__DIR__ . '/output/01 - example of the statement.txt') |
| 33 | + ); |
| 34 | + } |
| 35 | + |
| 36 | + /** |
| 37 | + * Test that the code can be executed for "No lake". |
| 38 | + * |
| 39 | + * @group surface_noLake |
| 40 | + */ |
| 41 | + public function testCanExecuteNoLake(): void |
| 42 | + { |
| 43 | + $this->expectExecuteOutputAnswer( |
| 44 | + __DIR__ . '/input/02 - no lake.txt', |
| 45 | + 0 . PHP_EOL |
| 46 | + ); |
| 47 | + } |
| 48 | + |
| 49 | + /** |
| 50 | + * Test that the code can be executed for "The area is a lake". |
| 51 | + * |
| 52 | + * @group surface_theAreaIsALake |
| 53 | + */ |
| 54 | + public function testCanExecuteTheAreaIsALake(): void |
| 55 | + { |
| 56 | + $this->expectExecuteOutputAnswer( |
| 57 | + __DIR__ . '/input/03 - the area is a lake.txt', |
| 58 | + file_get_contents(__DIR__ . '/output/03 - the area is a lake.txt') |
| 59 | + ); |
| 60 | + } |
| 61 | + |
| 62 | + /** |
| 63 | + * Test that the code can be executed for "1 lake on a small map". |
| 64 | + * |
| 65 | + * @group surface_1LakeOnASmallMap |
| 66 | + */ |
| 67 | + public function testCanExecute1LakeOnASmallMap(): void |
| 68 | + { |
| 69 | + $this->expectExecuteOutputAnswer( |
| 70 | + __DIR__ . '/input/04 - 1 lake on a small map.txt', |
| 71 | + file_get_contents(__DIR__ . '/output/04 - 1 lake on a small map.txt') |
| 72 | + ); |
| 73 | + } |
| 74 | + |
| 75 | + /** |
| 76 | + * Test that the code can be executed for "Several lakes on a small map". |
| 77 | + * |
| 78 | + * @group surface_severalLakesOnASmallMap |
| 79 | + */ |
| 80 | + public function testCanExecuteSeveralLakesOnASmallMap(): void |
| 81 | + { |
| 82 | + $this->expectExecuteOutputAnswer( |
| 83 | + __DIR__ . '/input/05 - several lakes on a small map.txt', |
| 84 | + file_get_contents(__DIR__ . '/output/05 - several lakes on a small map.txt') |
| 85 | + ); |
| 86 | + } |
| 87 | + |
| 88 | + /** |
| 89 | + * Test that the code can be executed for "Some lakes on a 20x20 map". |
| 90 | + * |
| 91 | + * @group surface_someLakesOnA20x20Map |
| 92 | + */ |
| 93 | + public function testCanExecuteSomeLakesOnA20x20Map(): void |
| 94 | + { |
| 95 | + $this->expectExecuteOutputAnswer( |
| 96 | + __DIR__ . '/input/06 - some lakes on a 20x20 map.txt', |
| 97 | + file_get_contents(__DIR__ . '/output/06 - some lakes on a 20x20 map.txt') |
| 98 | + ); |
| 99 | + } |
| 100 | + |
| 101 | + /** |
| 102 | + * Test that the code can be executed for "Many lakes on a 100x50 map". |
| 103 | + * |
| 104 | + * @group surface_manyLakesOnA100x50Map |
| 105 | + */ |
| 106 | + public function testCanExecuteManyLakesOnA100x50Map(): void |
| 107 | + { |
| 108 | + $this->expectExecuteOutputAnswer( |
| 109 | + __DIR__ . '/input/07 - many lakes on a 100x50 map.txt', |
| 110 | + file_get_contents(__DIR__ . '/output/07 - many lakes on a 100x50 map.txt') |
| 111 | + ); |
| 112 | + } |
| 113 | + |
| 114 | + /** |
| 115 | + * Test that the code can be executed for "100 tests on a 1000x1000 map". |
| 116 | + * |
| 117 | + * @group surface_100TestsOnA1000x1000Map |
| 118 | + */ |
| 119 | + public function testCanExecute100TestsOnA1000x1000Map(): void |
| 120 | + { |
| 121 | + $this->expectExecuteOutputAnswer( |
| 122 | + __DIR__ . '/input/08 - 100 tests on a 1000x1000 map.txt', |
| 123 | + file_get_contents(__DIR__ . '/output/08 - 100 tests on a 1000x1000 map.txt') |
| 124 | + ); |
| 125 | + } |
| 126 | + |
| 127 | + /** |
| 128 | + * Test that the code can be executed for "Large map, large lake". |
| 129 | + * |
| 130 | + * @group surface_largeMapLargeLake |
| 131 | + */ |
| 132 | + public function testCanExecuteLargeMapLargeLake(): void |
| 133 | + { |
| 134 | + $this->expectExecuteOutputAnswer( |
| 135 | + __DIR__ . '/input/09 - large map, large lake.txt', |
| 136 | + 359997 . PHP_EOL |
| 137 | + ); |
| 138 | + } |
| 139 | +} |
0 commit comments