Skip to content

Commit

Permalink
use assertion with Delta on PHPUnit float values
Browse files Browse the repository at this point in the history
  • Loading branch information
WengerK committed Jul 12, 2023
1 parent 7473e61 commit e033b73
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 12 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- update changelog following 'keep a changelog' format
- run code-styles Github Actions on PHP 8.1
- update symfony checker to use new symfonycorp/security-checker-action
- use assertion with Delta on PHPUnit float values

### Added
- add run of tests on Github Actions
Expand Down
10 changes: 4 additions & 6 deletions tests/SwisstopoConverterWGSToMN03Tests.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,8 @@ public function testFromMN03ToWGS(): void
{
$swiss_converter = new SwisstopoConverter();
$coordinates = $swiss_converter->fromMN03ToWGS(554680, 145807);
$this->assertSame([
'lat' => 46.462057617639346,
'long' => 6.848673659076181,
], $coordinates);
$this->assertEqualsWithDelta(46.462057617639, $coordinates['lat'], 0.0001);
$this->assertEqualsWithDelta(6.8486736590762, $coordinates['long'], 0.0001);
}

/**
Expand All @@ -48,7 +46,7 @@ public function testFromMN03ToWGSLatitude(): void
{
$swiss_converter = new SwisstopoConverter();
$latitude = $this->invokeMethod($swiss_converter, 'fromMN03ToWGSLatitude', [554680, 145807]);
$this->assertEquals(46.462057617639, $latitude);
$this->assertEqualsWithDelta(46.462057617639, $latitude, 0.0001);
}

/**
Expand All @@ -60,7 +58,7 @@ public function testFromMN03ToWGSLongitude(): void
{
$swiss_converter = new SwisstopoConverter();
$longitude = $this->invokeMethod($swiss_converter, 'fromMN03ToWGSLongitude', [554680, 145807]);
$this->assertEquals(6.8486736590762, $longitude);
$this->assertEqualsWithDelta(6.8486736590762, $longitude, 0.0001);
}

/**
Expand Down
10 changes: 4 additions & 6 deletions tests/SwisstopoConverterWGSToMN95Tests.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,8 @@ public function testFromMN95ToWGS(): void
{
$swiss_converter = new SwisstopoConverter();
$coordinates = $swiss_converter->fromMN95ToWGS(2555047, 1145923);
$this->assertSame([
'lat' => 46.46312579498212,
'long' => 6.8534397262208095,
], $coordinates);
$this->assertEqualsWithDelta(46.463125794982, $coordinates['lat'], 0.0001);
$this->assertEqualsWithDelta(6.8534397262208, $coordinates['long'], 0.0001);
}

/**
Expand Down Expand Up @@ -74,7 +72,7 @@ public function testFromMN95ToWGSLatitude(): void
{
$swiss_converter = new SwisstopoConverter();
$latitude = $this->invokeMethod($swiss_converter, 'fromMN95ToWGSLatitude', [2555047, 1145923]);
$this->assertEquals(46.463125794982, $latitude);
$this->assertEqualsWithDelta(46.463125794982, $latitude, 0.0001);
}

/**
Expand All @@ -86,6 +84,6 @@ public function testFromMN95ToWGSLongitude(): void
{
$swiss_converter = new SwisstopoConverter();
$longitude = $this->invokeMethod($swiss_converter, 'fromMN95ToWGSLongitude', [2555047, 1145923]);
$this->assertEquals(6.8534397262208, $longitude);
$this->assertEqualsWithDelta(6.8534397262208, $longitude, 0.0001);
}
}

0 comments on commit e033b73

Please sign in to comment.