19 declare(strict_types=1);
33 $this->assertInstanceOf(Range::class,
$range);
37 #[\PHPUnit\Framework\Attributes\Depends('testFactory')] 40 $this->assertEquals(1, $range->
getStart());
41 $this->assertEquals(2, $range->
getLength());
44 #[\PHPUnit\Framework\Attributes\Depends('testFactory')] 47 $this->assertEquals(3, $range->
getEnd());
50 #[\PHPUnit\Framework\Attributes\Depends('testFactory')] 54 $this->assertEquals(1, $range->
getStart());
55 $this->assertEquals(3, $range->
getLength());
56 $this->assertEquals(4, $range->
getEnd());
60 #[\PHPUnit\Framework\Attributes\Depends('testWithLength')] 64 $this->assertEquals(3, $range->
getStart());
65 $this->assertEquals(3, $range->
getLength());
66 $this->assertEquals(6, $range->
getEnd());
70 #[\PHPUnit\Framework\Attributes\Depends('testWithStart')] 79 #[\PHPUnit\Framework\Attributes\Depends('testFactory')] 82 $this->expectException(InvalidArgumentException::class);
86 #[\PHPUnit\Framework\Attributes\Depends('testFactory')] 89 $this->expectException(InvalidArgumentException::class);
95 $this->expectException(InvalidArgumentException::class);
102 $this->expectException(InvalidArgumentException::class);
107 #[\PHPUnit\Framework\Attributes\DataProvider('cropCases')] 111 $range =
$f->range($start, $length);
115 $this->assertEquals(
$range, $cropped);
117 $this->assertEquals(min($max, $start), $cropped->getStart());
118 $this->assertEquals($max, $cropped->getEnd());
125 [0, 100, 1000,
false],
126 [0, 1000, 100,
true],
128 [50, 100, 200,
false],
testNegativeStart(Range $range)
testConstructionWrongStart()
testNegativeLength(Range $range)
testEndCalculation(Range $range)
testConstructionWrongLength()
testWithStart(Range $range)
croppedTo(int $max)
This will create a range that is guaranteed to not exceed $max.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
testWithLength(Range $range)
testCroppedTo($start, $length, $max, $has_changed)
A simple class to express a naive range of whole positive numbers.