Skip to content

Commit

Permalink
Address RT#121969
Browse files Browse the repository at this point in the history
  • Loading branch information
nigelhorne committed Jun 2, 2017
1 parent d04a840 commit 71934ae
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 24 deletions.
20 changes: 15 additions & 5 deletions t/ca.t
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

use warnings;
use strict;
use Test::Number::Delta within => 1e-2;
use Test::Most tests => 9;
use Test::NoWarnings;

Expand All @@ -14,14 +13,25 @@ CA: {
SKIP: {
skip 'Test requires Internet access', 7 unless(-e 't/online.enabled');

eval {
require Test::Number::Delta;

Test::Number::Delta->import();
};

if($@) {
diag('Test::Number::Delta not installed - skipping tests');
skip 'Test::Number::Delta not installed', 7;
}

my $geocoder = new_ok('Geo::Coder::XYZ');
my $location = $geocoder->geocode('9235 Main St, Richibucto, New Brunswick, Canada');
delta_ok($location->{latt}, 46.67);
delta_ok($location->{longt}, -64.87);
delta_within($location->{latt}, 46.67, 1e-2);
delta_within($location->{longt}, -64.87, 1e-2);

$location = $geocoder->geocode(location => '9235 Main St, Richibucto, New Brunswick, Canada');
delta_ok($location->{latt}, 46.67);
delta_ok($location->{longt}, -64.87);
delta_within($location->{latt}, 46.67, 1e-2);
delta_within($location->{longt}, -64.87, 1e-2);

my $address = $geocoder->reverse_geocode(latlng => '46.67,-64.87');
like($address->{'city'}, qr/Richibucto/i, 'test reverse');
Expand Down
24 changes: 17 additions & 7 deletions t/uk.t
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

use warnings;
use strict;
use Test::Number::Delta within => 1e-2;
use Test::Most tests => 11;

BEGIN {
Expand All @@ -19,19 +18,30 @@ UK: {
require Test::Carp;
Test::Carp->import();;

eval {
require Test::Number::Delta;

Test::Number::Delta->import();
};

if($@) {
diag('Test::Number::Delta not installed - skipping tests');
skip 'Test::Number::Delta not installed', 10;
}

my $geocoder = new_ok('Geo::Coder::XYZ');

my $location = $geocoder->geocode('10 Downing St., London, UK');
delta_ok($location->{latt}, 51.50);
delta_ok($location->{longt}, -0.13);
delta_within($location->{latt}, 51.50, 1e-2);
delta_within($location->{longt}, -0.13, 1e-2);

$location = $geocoder->geocode('Wokingham, Berkshire, England');
delta_ok($location->{latt}, 51.41);
delta_ok($location->{longt}, -0.83);
delta_within($location->{latt}, 51.41, 1e-2);
delta_within($location->{longt}, -0.83, 1e-2);

$location = $geocoder->geocode(location => '10 Downing St., London, UK');
delta_ok($location->{latt}, 51.50);
delta_ok($location->{longt}, -0.13);
delta_within($location->{latt}, 51.50, 1e-2);
delta_within($location->{longt}, -0.13, 1e-2);

my $address = $geocoder->reverse_geocode(latlng => '51.50,-0.13');
like($address->{'city'}, qr/^London$/i, 'test reverse');
Expand Down
13 changes: 1 addition & 12 deletions t/us.t
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,7 @@ XYZ: {
SKIP: {
skip 'Test requires Internet access', 4 unless(-e 't/online.enabled');

eval {
require Test::Number::Delta;

Test::Number::Delta->import();
};

if($@) {
diag('Geo::Coder::XYZ not installed - skipping tests');
skip 'Geo::Coder::XYZ not installed', 4;
} else {
diag("Using Geo::Coder::XYZ $Geo::Coder::XYZ::VERSION");
}
diag("Using Geo::Coder::XYZ $Geo::Coder::XYZ::VERSION");

my $geocoder = new_ok('Geo::Coder::XYZ');

Expand Down

0 comments on commit 71934ae

Please sign in to comment.