2014-06-30 20:38:48 -07:00
|
|
|
|
#!/usr/bin/env perl
|
|
|
|
|
|
|
|
|
|
use strict;
|
|
|
|
|
use warnings;
|
|
|
|
|
use Test::More;
|
|
|
|
|
use DDG::Test::Goodie;
|
|
|
|
|
use utf8;
|
|
|
|
|
|
|
|
|
|
zci answer_type => 'convertlatlon';
|
|
|
|
|
zci is_cached => 1;
|
|
|
|
|
|
|
|
|
|
ddg_goodie_test(
|
|
|
|
|
[qw(
|
|
|
|
|
DDG::Goodie::ConvertLatLon
|
|
|
|
|
)],
|
|
|
|
|
|
|
|
|
|
#Primary example
|
|
|
|
|
'71° 10\' 3" in decimal' => test_zci('71.1675°', html => qr/71\.1675/),
|
|
|
|
|
|
|
|
|
|
#Secondary examples
|
|
|
|
|
'71 degrees 10 minutes 3 seconds east in decimal' => test_zci('71.1675°', html => qr/71\.1675/),
|
|
|
|
|
|
|
|
|
|
#Latitudes and longitudes of cities, various trigger combinations
|
|
|
|
|
#Values from Wikipedia/GeoHack toolserver
|
|
|
|
|
#Sydney
|
|
|
|
|
'convert 151.2094° E to degrees minutes seconds' => test_zci('151° 12′ 34″ E', html => qr/151.+12.+34.+E/),
|
|
|
|
|
#Moscow
|
|
|
|
|
'55° 45′ 00″ in decimal' => test_zci('55.75°', html => qr/55.75/),
|
|
|
|
|
#Kinshasha
|
|
|
|
|
'kinshasha is 15.322222 degrees east convert to dms' => test_zci('15° 19′ 20″ E', html => qr/15.+19.+20.+E/),
|
|
|
|
|
#Copenhagen
|
|
|
|
|
'55.676111° latitude' => test_zci('55° 40′ 34″', html => qr/55.+40.+34/),
|
|
|
|
|
#La Paz
|
|
|
|
|
'- 68º 9\' 0" as decimal' => test_zci('−68.15°', html => qr/−68.15/),
|
|
|
|
|
|
|
|
|
|
#If two coordinates are given (e.g. lat/lon), only the first will be converted
|
|
|
|
|
'20 º 10 \' 0 " S, 57 deg 31 min 0 sec E convert' => test_zci('−20.166667°', html => qr/−20\.166667/),
|
|
|
|
|
|
|
|
|
|
#Make sure "plural S" works
|
|
|
|
|
"68 degrees 9 minutes S in decimal form" => test_zci('−68.15°', html => qr/−68.15/),
|
|
|
|
|
|
|
|
|
|
#Should not trigger for impossible latitudes and longitudes
|
|
|
|
|
'95º 4\' N as decimal' => undef,
|
|
|
|
|
'convert 293.11 degrees to dms' => undef,
|
|
|
|
|
|
|
|
|
|
#Should not trigger for impossible combinations of sign and
|
|
|
|
|
# cardinal direction
|
|
|
|
|
'-71º 12\' 51" S as a decimal latitude' => undef,
|
|
|
|
|
|
|
|
|
|
#Should not trigger on unrelated queries
|
|
|
|
|
'convert 61.01º farenheit to celcius' => undef,
|
|
|
|
|
'how many degrees in a 12-sided polygon internal angles' => undef,
|
|
|
|
|
'convert 61.125 degrees to radians' => undef,
|
2014-07-01 20:39:23 -07:00
|
|
|
|
'are there more than 100 seconds in a day' => undef,
|
|
|
|
|
'convert 4 minute mile to kilometers' => undef,
|
|
|
|
|
'attack of the 50\' 4" woman' => undef,
|
|
|
|
|
'is 39.75 degrees a fever' => undef,
|
2014-06-30 20:38:48 -07:00
|
|
|
|
|
2014-07-01 21:33:02 -07:00
|
|
|
|
#Check for css
|
|
|
|
|
'71° 10\' 3" in decimal' => test_zci(qr/./, html => qr/css/),
|
|
|
|
|
|
2014-06-30 20:38:48 -07:00
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
done_testing;
|
|
|
|
|
|