1 #------------------------------------------------------------------------------
2 # Test script for CPAN module Locale::SubCountry
5 #------------------------------------------------------------------------------
9 use Locale::SubCountry;
11 # We start with some black magic to print on failure.
13 BEGIN { print "1..15\n"; }
15 my $australia = new Locale::SubCountry('Australia');
16 print $australia->code('New South Wales ') eq 'NSW' ? "ok 1\n" : "not ok 1\n";
17 print $australia->full_name('S.A.') eq 'South Australia' ? "ok 2\n" : "not ok 2\n";
20 print $australia->full_name('Qld',$upper_case) eq 'QUEENSLAND' ? "ok 3\n" : "not ok 3\n";
22 print $australia->country_code eq 'AU' ? "ok 4\n" : "not ok 4\n";
24 print $australia->category('NSW') eq 'state' ? "ok 5\n" : "not ok 5\n";
26 print $australia->ISO3166_2_code('01') eq 'ACT' ? "ok 6\n" : "not ok 6\n";
28 print $australia->FIPS10_4_code('ACT') eq '01' ? "ok 7\n" : "not ok 7\n";
30 my %states = $australia->full_name_code_hash;
31 print $states{'Tasmania'} eq 'TAS' ? "ok 8\n" : "not ok 8\n";
33 %states = $australia->code_full_name_hash;
34 print $states{'SA'} eq 'South Australia' ? "ok 9\n" : "not ok 9\n";
36 my @states = $australia->all_codes;
37 print @states == 8 ? "ok 10\n" : "not ok 10\n";
39 my @all_names = $australia->all_full_names;
40 print $all_names[1] eq 'New South Wales' ? "ok 11\n" : "not ok 11\n";
42 my $world = new Locale::SubCountry::World;
44 my %countries = $world->full_name_code_hash;
45 print $countries{'NEW ZEALAND'} eq 'NZ' ? "ok 12\n" : "not ok 12\n";
47 %countries = $world->code_full_name_hash;
48 print $countries{'GB'} eq 'UNITED KINGDOM' ? "ok 13\n" : "not ok 13\n";
50 my @all_country_codes = $world->all_codes;
51 print @all_country_codes ? "ok 14\n" : "not ok 14\n";
53 my @all_country_names = $world->all_full_names;
54 print @all_country_names ? "ok 15\n" : "not ok 15\n";