Debian Codegraph @

t/00-Ham-Locator.t

raw symbols SCIP
1 # Before `make install' is performed this script should be runnable with
2 # `make test'. After `make install' it should work as `perl IPTables-Log.t'
3
4 #########################
5
6 # change 'tests => 1' to 'tests => last_test_to_print';
7
8 use Test::More tests => 11;
9 BEGIN { use_ok('Ham::Locator') };
10
11 #########################
12
13 # Insert your test code below, the Test::More module is use()ed here so read
14 # its man page ( perldoc Test::More ) for help writing this test script.
15
16 # Create new IPTables::Log object
17 my $l = new_ok( Ham::Locator );
18 # Check it's of the correct type
19 ok(ref($l) eq "Ham::Locator", "Object is of type Ham::Locator");
20
21 diag("Testing methods");
22 can_ok($l, qw(latlng2loc loc2latlng n2l l2n));
23
24 diag("Testing loc2latlng...");
25 $l->set_loc("IO93lo72hn");
26 my @latlng = $l->loc2latlng();
27 like($latlng[0], qr/^53.593923/, "Correct latitude returned");
28 like($latlng[1], qr/^-1.022569/, "Correct longitude returned");
29
30 diag("Testing latlng2loc...");
31 $l->set_latlng((53.593923, -1.022569));
32 my $loc = $l->latlng2loc();
33 like($loc, qr/IO93lo72hn/, "Correct locator returned");
34
35 diag("Testing precision (to 8 places)...");
36 $l->set_precision(8);
37 $loc = $l->latlng2loc();
38 like($loc, qr/IO93lo72/, "Correct locator returned (to 6 places)");
39
40 diag("Testing precision (to 6 places)...");
41 $l->set_precision(6);
42 $loc = $l->latlng2loc();
43 like($loc, qr/IO93lo/, "Correct locator returned (to 6 places)");
44
45 diag("Testing precision (to 4 places)...");
46 $l->set_precision(4);
47 $loc = $l->latlng2loc();
48 like($loc, qr/IO93/, "Correct locator returned (to 4 places)");
49
50 diag("Testing precision (to 2 places)...");
51 $l->set_precision(2);
52 $loc = $l->latlng2loc();
53 like($loc, qr/IO/, "Correct locator returned (to 4 places)");
54