]> git.ipfire.org Git - location/libloc.git/commitdiff
perl: Testsuite: Add tests for lookup_asn()
authorStefan Schantl <stefan.schantl@ipfire.org>
Wed, 2 Oct 2019 17:25:51 +0000 (19:25 +0200)
committerMichael Tremer <michael.tremer@ipfire.org>
Thu, 3 Oct 2019 18:44:02 +0000 (18:44 +0000)
Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/perl/t/Location.t

index 55a18f3c320c79bc76a2b2c9507d5fc751439aba..fd43946deb447b4775dae771b9e1895be2d9f12a 100644 (file)
@@ -11,7 +11,7 @@ use warnings;
 # Where to find the test database.
 my $testdb = $ENV{'database'};
 
-use Test::More tests => 5;
+use Test::More tests => 6;
 BEGIN { use_ok('Location') };
 
 #########################
@@ -42,3 +42,12 @@ if(defined($country_code)) { fail("Test 5 - Lookup country code for address not
 
 $country_code = &Location::lookup_country_code($db, "a.b.c.d");
 if(defined($country_code)) { fail("Test 6 - Lookup country code for invalid address.") }
+
+my $as_number = &Location::lookup_asn($db, $address);
+ok($as_number eq "204867", "Test 7 - Lookup Autonomous System Number for $address.");
+
+$as_number = &Location::lookup_asn($db, "1.1.1.1");
+if(defined($as_number)) { fail("Test 8 - Lookup Autonomous System Number for address not in Database.") }
+
+$as_number = &Location::lookup_asn($db, "a.b.c.d");
+if(defined($as_number)) { fail("Test 9 - Lookup Autonomous System Number for invalid address.") }