|
5 | 5 | use InvalidArgumentException; |
6 | 6 | use PHPUnit\Framework\Attributes\DataProvider; |
7 | 7 | use PHPUnit\Framework\TestCase; |
| 8 | +use Vectorial1024\OpenLocationCodePhp\CodeCalculator\CodeCalculatorFloat; |
| 9 | +use Vectorial1024\OpenLocationCodePhp\CodeCalculator\CodeCalculatorInt; |
8 | 10 | use Vectorial1024\OpenLocationCodePhp\OpenLocationCode; |
9 | 11 |
|
10 | 12 | class OpenLocationCodeTest extends TestCase |
@@ -38,6 +40,17 @@ public function testCorrectCodeFromCoordinates(float $latitude, float $longitude |
38 | 40 | $this->assertEquals($expectedCode, $codeObject->code); |
39 | 41 | // while OLC represents an area via lossful encoding, at least the area should contain the original point |
40 | 42 | $this->assertTrue($codeObject->contains($latitude, $longitude)); |
| 43 | + |
| 44 | + // for convenience, also test the code calculators here |
| 45 | + $floatCal = new CodeCalculatorFloat(); |
| 46 | + $resultCode = $floatCal->encode($latitude, $longitude, OpenLocationCode::CODE_PRECISION_NORMAL); |
| 47 | + $this->assertEquals($resultCode, $expectedCode); |
| 48 | + if (PHP_INT_SIZE >= 8) { |
| 49 | + // at least 64-bit, which means we can use "long" ints here |
| 50 | + $intCal = new CodeCalculatorInt(); |
| 51 | + $resultCode = $intCal->encode($latitude, $longitude, OpenLocationCode::CODE_PRECISION_NORMAL); |
| 52 | + $this->assertEquals($resultCode, $expectedCode); |
| 53 | + } |
41 | 54 | } |
42 | 55 |
|
43 | 56 | public static function codeValidityProvider(): array |
|
0 commit comments