File: 002_adjacent.t

package info (click to toggle)
libgeo-hash-xs-perl 0.00015-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 412 kB
  • sloc: perl: 1,981; ansic: 55; makefile: 3
file content (27 lines) | stat: -rw-r--r-- 915 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
use strict;
use warnings;
use Test::More;
use Geo::Hash::XS qw(:adjacent);

ok my $gh = Geo::Hash::XS->new;
isa_ok $gh, 'Geo::Hash::XS';

# Made these tests by using 
# http://blog.masuidrive.jp/wp-content/uploads/2010/01/geohash.html
is $gh->adjacent('xn76gg', ADJ_RIGHT), lc 'xn76u5'; # RIGHT
is $gh->adjacent('xn76gg', ADJ_LEFT), lc 'xn76ge'; # LEFT
is $gh->adjacent('xn76gg', ADJ_TOP), lc 'xn76gu'; # TOP
is $gh->adjacent('xn76gg', ADJ_BOTTOM), lc 'xn76gf'; # BOTTOM

is $gh->adjacent('xpst02vt', ADJ_RIGHT), 'xpst02vv'; # RIGHT
is $gh->adjacent('xpst02vt', ADJ_LEFT), 'xpst02vm'; # LEFT
is $gh->adjacent('xpst02vt', ADJ_TOP), 'xpst02vw'; # TOP
is $gh->adjacent('xpst02vt', ADJ_BOTTOM), 'xpst02vs'; # BOTTOM

# Check edge cases
is $gh->adjacent('00', ADJ_BOTTOM), 'bp';
is $gh->adjacent('00', ADJ_LEFT)  , 'pb';
is $gh->adjacent('zz', ADJ_TOP)   , 'pb';
is $gh->adjacent('zz', ADJ_RIGHT) , 'bp';

done_testing;