summaryrefslogtreecommitdiff
path: root/t
diff options
context:
space:
mode:
Diffstat (limited to 't')
-rw-r--r--t/00-load.t9
-rw-r--r--t/01-lookup.t19
-rw-r--r--t/02-fail.t16
3 files changed, 44 insertions, 0 deletions
diff --git a/t/00-load.t b/t/00-load.t
new file mode 100644
index 0000000..46f282f
--- /dev/null
+++ b/t/00-load.t
@@ -0,0 +1,9 @@
+#!perl -T
+
+use Test::More tests => 1;
+
+BEGIN {
+ use_ok( 'Geo::USCensus::Geocoding' ) || print "Bail out!\n";
+}
+
+diag( "Testing Geo::USCensus::Geocoding $Geo::USCensus::Geocoding, Perl $], $^X" );
diff --git a/t/01-lookup.t b/t/01-lookup.t
new file mode 100644
index 0000000..11c8b37
--- /dev/null
+++ b/t/01-lookup.t
@@ -0,0 +1,19 @@
+#!perl -T
+
+use Test::More tests => 2;
+use Data::Dumper;
+use Geo::USCensus::Geocoding;
+
+diag( "Testing lookup of a known good address" );
+my $result = Geo::USCensus::Geocoding->query(
+ street => '1526 H St', # the California Governor's Mansion
+ city => 'Sacramento',
+ state => 'CA',
+ zip => '95814',
+);
+
+is( $result->message, '', 'error status' );
+is( $result->matches, 1, 'number of matches' );
+diag($result->match(0)->matchedAddress);
+diag('Census tract '.$result->match(0)->censustract);
+
diff --git a/t/02-fail.t b/t/02-fail.t
new file mode 100644
index 0000000..72fc6da
--- /dev/null
+++ b/t/02-fail.t
@@ -0,0 +1,16 @@
+#!perl -T
+
+use Test::More tests => 1;
+use Data::Dumper;
+use Geo::USCensus::Geocoding;
+
+diag( "Testing lookup of a known nonexistent address" );
+my $result = Geo::USCensus::Geocoding->query(
+ street => '1000 Z St', # there is no Z street
+ city => 'Sacramento',
+ state => 'CA',
+ zip => '95814',
+);
+
+is( $result->matches, 0, 'number of matches' );
+