3declare(strict_types=1);
 
    6use PHPUnit\Framework\TestCase;
 
   16        $range = 
$f->range(1, 2);
 
   17        $this->assertInstanceOf(Range::class, $range);
 
   26        $this->assertEquals(1, $range->
getStart());
 
   27        $this->assertEquals(2, $range->
getLength());
 
   35        $this->assertEquals(3, $range->
getEnd());
 
   44        $this->assertEquals(1, $range->
getStart());
 
   45        $this->assertEquals(3, $range->
getLength());
 
   46        $this->assertEquals(4, $range->
getEnd());
 
   56        $this->assertEquals(3, $range->
getStart());
 
   57        $this->assertEquals(3, $range->
getLength());
 
   58        $this->assertEquals(6, $range->
getEnd());
 
   78        $this->expectException(InvalidArgumentException::class);
 
   87        $this->expectException(InvalidArgumentException::class);
 
   93        $this->expectException(InvalidArgumentException::class);
 
   95        $range = 
$f->range(-1, 2);
 
  100        $this->expectException(InvalidArgumentException::class);
 
  102        $range = 
$f->range(1, -2);
 
  111        $range = 
$f->range($start, $length);
 
  112        $cropped = $range->croppedTo($max);
 
  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],
 
A simple class to express a range of whole positive numbers.
 
getEnd()
getEnd will return the (excluded) endpoint.
 
testConstructionWrongLength()
 
testUnpack(Range $range)
@depends testWithStart
 
testConstructionWrongStart()
 
testWithLength(Range $range)
@depends testFactory
 
testNegativeLength(Range $range)
@depends testFactory
 
testWithStart(Range $range)
@depends testWithLength
 
testNegativeStart(Range $range)
@depends testFactory
 
testEndCalculation(Range $range)
@depends testFactory
 
testValues(Range $range)
@depends testFactory
 
testCroppedTo($start, $length, $max, $has_changed)
@dataProvider cropCases