File: 03_methods.t

package info (click to toggle)
libgeo-distance-xs-perl 0.13-2
  • links: PTS, VCS
  • area: main
  • in suites: buster, jessie, jessie-kfreebsd, stretch
  • size: 256 kB
  • ctags: 763
  • sloc: ansic: 3,222; perl: 134; makefile: 11
file content (23 lines) | stat: -rw-r--r-- 626 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
use strict;
use warnings;
use Geo::Distance::XS;
use Test::More;

my @formulas = @Geo::Distance::XS::FORMULAS;
for my $f (@formulas) {
    my $geo = Geo::Distance->new;
    $geo->formula($f);

    my @coords = (-118.243103, 34.159545, -73.987427, 40.853293);
    my %expected = (
        map({ $_ => 2443 } @formulas), polar => 2766, tv => 2448, alt => 2448,
    );
    my $d = $geo->distance(mile => @coords);
    is int $d, $expected{$f}, "$f: distance from LA to NY";

    @coords = (175, 12, -5, -12);
    $d = $geo->distance(mile => @coords);
    ok $d == $d, "$f with antipodal coordinates is not NaN";
}

done_testing;