ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
RangeTest Class Reference
+ Inheritance diagram for RangeTest:
+ Collaboration diagram for RangeTest:

Public Member Functions

 testFactory ()
 
 testValues (Range $range)
 testFactory More...
 
 testEndCalculation (Range $range)
 testFactory More...
 
 testWithLength (Range $range)
 testFactory More...
 
 testWithStart (Range $range)
 testWithLength More...
 
 testUnpack (Range $range)
 testWithStart More...
 
 testNegativeStart (Range $range)
 testFactory More...
 
 testNegativeLength (Range $range)
 testFactory More...
 
 testConstructionWrongStart ()
 
 testConstructionWrongLength ()
 
 testCroppedTo ($start, $length, $max, $has_changed)
 cropCases More...
 
 cropCases ()
 

Detailed Description

Member Function Documentation

◆ cropCases()

RangeTest::cropCases ( )

Definition at line 122 of file RangeTest.php.

122  : array
123  {
124  return [
125  [0, 100, 1000, false],
126  [0, 1000, 100, true],
127  [50, 100, 75, true],
128  [50, 100, 200, false],
129  [100, 100, 50, true]
130  ];
131  }

◆ testConstructionWrongLength()

RangeTest::testConstructionWrongLength ( )

Definition at line 98 of file RangeTest.php.

References Vendor\Package\$f.

98  : void
99  {
100  $this->expectException(InvalidArgumentException::class);
101  $f = new ILIAS\Data\Factory();
102  $range = $f->range(1, -2);
103  }

◆ testConstructionWrongStart()

RangeTest::testConstructionWrongStart ( )

Definition at line 91 of file RangeTest.php.

References Vendor\Package\$f.

91  : void
92  {
93  $this->expectException(InvalidArgumentException::class);
94  $f = new ILIAS\Data\Factory();
95  $range = $f->range(-1, 2);
96  }

◆ testCroppedTo()

RangeTest::testCroppedTo (   $start,
  $length,
  $max,
  $has_changed 
)

cropCases

Definition at line 108 of file RangeTest.php.

References Vendor\Package\$f.

108  : void
109  {
110  $f = new ILIAS\Data\Factory();
111  $range = $f->range($start, $length);
112  $cropped = $range->croppedTo($max);
113 
114  if (!$has_changed) {
115  $this->assertEquals($range, $cropped);
116  } else {
117  $this->assertEquals(min($max, $start), $cropped->getStart());
118  $this->assertEquals($max, $cropped->getEnd());
119  }
120  }

◆ testEndCalculation()

RangeTest::testEndCalculation ( Range  $range)

testFactory

Definition at line 33 of file RangeTest.php.

References ILIAS\Data\Range\getEnd().

33  : void
34  {
35  $this->assertEquals(3, $range->getEnd());
36  }
getEnd()
getEnd will return the (excluded) endpoint.
Definition: Range.php:76
+ Here is the call graph for this function:

◆ testFactory()

RangeTest::testFactory ( )

Definition at line 13 of file RangeTest.php.

References Vendor\Package\$f.

13  : Range
14  {
15  $f = new ILIAS\Data\Factory();
16  $range = $f->range(1, 2);
17  $this->assertInstanceOf(Range::class, $range);
18  return $range;
19  }
A simple class to express a range of whole positive numbers.
Definition: Range.php:30

◆ testNegativeLength()

RangeTest::testNegativeLength ( Range  $range)

testFactory

Definition at line 85 of file RangeTest.php.

References ILIAS\Data\Range\withLength().

85  : void
86  {
87  $this->expectException(InvalidArgumentException::class);
88  $range = $range->withLength(-1);
89  }
withLength(int $length)
Definition: Range.php:93
+ Here is the call graph for this function:

◆ testNegativeStart()

RangeTest::testNegativeStart ( Range  $range)

testFactory

Definition at line 76 of file RangeTest.php.

References ILIAS\Data\Range\withStart().

76  : void
77  {
78  $this->expectException(InvalidArgumentException::class);
79  $range = $range->withStart(-5);
80  }
withStart(int $start)
Definition: Range.php:85
+ Here is the call graph for this function:

◆ testUnpack()

RangeTest::testUnpack ( Range  $range)

testWithStart

Definition at line 65 of file RangeTest.php.

References ILIAS\Data\Range\unpack().

65  : void
66  {
67  $this->assertEquals(
68  [3,3],
69  $range->unpack()
70  );
71  }
+ Here is the call graph for this function:

◆ testValues()

RangeTest::testValues ( Range  $range)

testFactory

Definition at line 24 of file RangeTest.php.

References ILIAS\Data\Range\getLength(), and ILIAS\Data\Range\getStart().

24  : void
25  {
26  $this->assertEquals(1, $range->getStart());
27  $this->assertEquals(2, $range->getLength());
28  }
+ Here is the call graph for this function:

◆ testWithLength()

RangeTest::testWithLength ( Range  $range)

testFactory

Definition at line 41 of file RangeTest.php.

References ILIAS\Data\Range\getEnd(), ILIAS\Data\Range\getLength(), ILIAS\Data\Range\getStart(), and ILIAS\Data\Range\withLength().

41  : Range
42  {
43  $range = $range->withLength(3);
44  $this->assertEquals(1, $range->getStart());
45  $this->assertEquals(3, $range->getLength());
46  $this->assertEquals(4, $range->getEnd());
47  return $range;
48  }
getEnd()
getEnd will return the (excluded) endpoint.
Definition: Range.php:76
withLength(int $length)
Definition: Range.php:93
A simple class to express a range of whole positive numbers.
Definition: Range.php:30
+ Here is the call graph for this function:

◆ testWithStart()

RangeTest::testWithStart ( Range  $range)

testWithLength

Definition at line 53 of file RangeTest.php.

References ILIAS\Data\Range\getEnd(), ILIAS\Data\Range\getLength(), ILIAS\Data\Range\getStart(), and ILIAS\Data\Range\withStart().

53  : Range
54  {
55  $range = $range->withStart(3);
56  $this->assertEquals(3, $range->getStart());
57  $this->assertEquals(3, $range->getLength());
58  $this->assertEquals(6, $range->getEnd());
59  return $range;
60  }
getEnd()
getEnd will return the (excluded) endpoint.
Definition: Range.php:76
withStart(int $start)
Definition: Range.php:85
A simple class to express a range of whole positive numbers.
Definition: Range.php:30
+ Here is the call graph for this function:

The documentation for this class was generated from the following file: