| 1 | <?php |
||
| 16 | class LambdaInterpolationTest extends \PHPUnit_Framework_TestCase |
||
| 17 | { |
||
| 18 | /** |
||
| 19 | * @expectedException InvalidArgumentException |
||
| 20 | */ |
||
| 21 | public function testInvalidClosure() |
||
| 22 | { |
||
| 23 | new LambdaInterpolation(function () { |
||
| 24 | return 1; |
||
| 25 | }); |
||
| 26 | } |
||
| 27 | |||
| 28 | /** |
||
| 29 | * @expectedException InvalidArgumentException |
||
| 30 | */ |
||
| 31 | public function testThatInvalidCallsAreDetected() |
||
| 32 | { |
||
| 33 | $Interpolation = new LambdaInterpolation(function ($x, $y, array $elevationOnBoundingBox) { |
||
| 34 | return 1; |
||
| 35 | }); |
||
| 36 | |||
| 37 | $Interpolation->interpolate(0.5, 0.14, [1, 2, 3]); |
||
| 38 | } |
||
| 39 | |||
| 40 | public function testConstantClosure() |
||
| 41 | { |
||
| 42 | $Interpolation = new LambdaInterpolation(function ($x, $y, array $elevationOnBoundingBox) { |
||
| 43 | return 42; |
||
| 44 | }); |
||
| 45 | |||
| 46 | $this->assertEquals(42, $Interpolation->interpolate(0.314, 0.42, [100, 100, 100, 100])); |
||
| 47 | } |
||
| 48 | } |
||
| 49 |