From 8983a47325879826eed1fb3324f8c3de9a7ba4a7 Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Wed, 5 Jul 2017 22:51:50 +0200 Subject: Use Test::Number::Delta for floating point comparisons This avoids issues caused by varying float behaviour on different systems --- t/21-iris-stations.t | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 't/21-iris-stations.t') diff --git a/t/21-iris-stations.t b/t/21-iris-stations.t index f68e5bb..497148b 100644 --- a/t/21-iris-stations.t +++ b/t/21-iris-stations.t @@ -4,7 +4,8 @@ use warnings; use 5.014; use utf8; -use Test::More tests => 15; +use Test::More tests => 17; +use Test::Number::Delta; BEGIN { use_ok('Travel::Status::DE::IRIS::Stations'); @@ -98,11 +99,14 @@ is_deeply( 'get_station_by_location: 10 matches for Foobar' ); +is(scalar Travel::Status::DE::IRIS::Stations::get_station_by_location(7.02458, 51.43862, 1), + 1, 'get_station_by_location(Foobar): only one match'); + is_deeply( - [ Travel::Status::DE::IRIS::Stations::get_station_by_location(7.02458, 51.43862, 1) ], - [ - [[ 'EESD', 'Essen Süd', 8001897, 7.023098, 51.439295], 0.127234298397033] - ], - 'get_station_by_location: 1 match with all data for Foobar' + (Travel::Status::DE::IRIS::Stations::get_station_by_location(7.02458, 51.43862, 1))[0][0], + [ 'EESD', 'Essen Süd', 8001897, 7.023098, 51.439295], + 'get_station_by_location(Foobar): correct location data' ); +delta_ok((Travel::Status::DE::IRIS::Stations::get_station_by_location(7.02458, 51.43862, 1))[0][1], + 0.127234298397033, 'get_station_by_location(Foobar): correct distance'); -- cgit v1.2.3