ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
All Data Structures Namespaces Files Functions Variables Modules Pages
OpenedFloatIntervalTest.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2019 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
8 namespace ILIAS\Data;
9 
13 
14 require_once 'libs/composer/vendor/autoload.php';
15 
17 {
21  public function testValidFloatRanges()
22  {
23  $floatRange = new OpenedFloatInterval(3.0, 100.4);
24 
25  $this->assertSame($floatRange->minimum(), 3.0);
26  $this->assertSame($floatRange->maximum(), 100.4);
27  }
28 
29  public function testValueIsInRange()
30  {
31  $range = new OpenedFloatInterval(3.0, 100.4);
32 
33  $this->assertTrue($range->spans(50));
34  }
35 
36  public function testMinimumValueIsInRange()
37  {
38  $range = new OpenedFloatInterval(3.0, 100.4);
39 
40  $this->assertTrue($range->spans(3));
41  }
42 
43  public function testMaximumValueIsInRange()
44  {
45  $range = new OpenedFloatInterval(3.0, 100.4);
46 
47  $this->assertTrue($range->spans(3));
48  }
49 
51  {
52  $range = new OpenedFloatInterval(3.0, 100.4);
53 
54  $this->assertFalse($range->spans(1));
55  }
56 
58  {
59  $range = new OpenedFloatInterval(3.0, 100.4);
60 
61  $this->assertFalse($range->spans(101));
62  }
63 
67  public function testHexIsAllowForRanges()
68  {
69  $floatRange = new OpenedFloatInterval(0x3, 0xA);
70 
71  $this->assertSame($floatRange->minimum(), 3.0);
72  $this->assertSame($floatRange->maximum(), 10.0);
73  }
74 
78  public function testBinaryIsAllowForRanges()
79  {
80  $floatRange = new OpenedFloatInterval(0b11, 0b1010);
81 
82  $this->assertSame($floatRange->minimum(), 3.0);
83  $this->assertSame($floatRange->maximum(), 10.0);
84  }
85 
89  public function testRangeCanBeSame()
90  {
91  $floatRange = new OpenedFloatInterval(3.0, 3.0);
92 
93  $this->assertSame($floatRange->minimum(), 3.0);
94  $this->assertSame($floatRange->maximum(), 3.0);
95  }
96 
98  {
99  $this->expectNotToPerformAssertions();
100 
101  try {
102  $floatRange = new OpenedFloatInterval(3.0, 1.0);
103  } catch (ConstraintViolationException $exception) {
104  return;
105  }
106  $this->fail();
107  }
108 }