|
1 | 1 | <?php |
| 2 | + |
2 | 3 | declare(strict_types=1); |
3 | 4 |
|
4 | 5 | namespace Danon\IntervalTree\Tests; |
|
12 | 13 | */ |
13 | 14 | final class IntervalTreeTest extends TestCase |
14 | 15 | { |
| 16 | + private const TREE_INTERVALS = [ |
| 17 | + [7, 8], [1, 4], [2, 3], [7, 12], [1, 1], [3, 4], [7, 7], [0, 2], [0, 2], [0, 3], [9, 12] |
| 18 | + ]; |
| 19 | + |
15 | 20 | /** @var IntervalTree */ |
16 | 21 | private $tree; |
17 | 22 |
|
18 | | - /** @var array<array<int>> */ |
19 | | - private $intervals = [[7, 8], [1, 4], [2, 3], [7, 12], [1, 1], [3, 4], [7, 7], [0, 2], [0, 2], [0, 3], [9, 12]]; |
20 | | - |
21 | 23 | public function setUp(): void |
22 | 24 | { |
23 | 25 | $this->tree = new IntervalTree(); |
24 | | - foreach ($this->intervals as $interval) { |
| 26 | + foreach (self::TREE_INTERVALS as $interval) { |
25 | 27 | $value = implode('-', $interval); |
26 | 28 | $this->tree->insert( |
27 | 29 | NumericInterval::fromArray($interval), |
@@ -83,7 +85,7 @@ public function testFindAnyIntersection(): void |
83 | 85 | public function testRemove(): void |
84 | 86 | { |
85 | 87 | $initialSize = $this->tree->getSize(); |
86 | | - self::assertEquals(count($this->intervals), $initialSize); |
| 88 | + self::assertEquals(count(self::TREE_INTERVALS), $initialSize); |
87 | 89 | self::assertTrue($this->tree->remove(NumericInterval::fromArray([7, 8]), '7-8')); |
88 | 90 | self::assertEquals($this->tree->getSize(), --$initialSize); |
89 | 91 | self::assertFalse($this->tree->remove(NumericInterval::fromArray([1, 4]), '1-3')); |
|
0 commit comments