summaryrefslogtreecommitdiff
path: root/t/main.t
blob: 304bee13a89c8a33ca39fea542538c09e2179144 (plain)
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#------------------------------------------------------------------------------
# Test script for CPAN module Locale::SubCountry 
#                                            
# Author: Kim Ryan 
#------------------------------------------------------------------------------

use strict;
use locale;
use Locale::SubCountry;

# We start with some black magic to print on failure.

BEGIN { print "1..15\n"; }

my $australia = new Locale::SubCountry('Australia');
print $australia->code('New South Wales ') eq 'NSW' ? "ok 1\n" : "not ok 1\n";
print $australia->full_name('S.A.') eq 'South Australia' ? "ok 2\n" : "not ok 2\n";

my $upper_case = 1;
print $australia->full_name('Qld',$upper_case) eq 'QUEENSLAND'  ? "ok 3\n" : "not ok 3\n";

print $australia->country_code eq 'AU' ? "ok 4\n" : "not ok 4\n";

print $australia->category('NSW') eq 'state' ? "ok 5\n" : "not ok 5\n";

print $australia->ISO3166_2_code('01') eq 'ACT' ? "ok 6\n" : "not ok 6\n";

print $australia->FIPS10_4_code('ACT') eq '01' ? "ok 7\n" : "not ok 7\n";

my %states =  $australia->full_name_code_hash;
print $states{'Tasmania'} eq 'TAS' ? "ok 8\n" : "not ok 8\n";

%states =  $australia->code_full_name_hash;
print $states{'SA'} eq 'South Australia' ? "ok 9\n" : "not ok 9\n";

my @states = $australia->all_codes;
print @states == 8 ? "ok 10\n" : "not ok 10\n";

my @all_names = $australia->all_full_names;
print $all_names[1] eq 'New South Wales' ? "ok 11\n" : "not ok 11\n";

my $world = new Locale::SubCountry::World;

my %countries =  $world->full_name_code_hash;
print $countries{'NEW ZEALAND'} eq 'NZ' ? "ok 12\n" : "not ok 12\n";

%countries =  $world->code_full_name_hash;
print $countries{'GB'} eq 'UNITED KINGDOM' ? "ok 13\n" : "not ok 13\n";

my @all_country_codes = $world->all_codes;
print @all_country_codes ? "ok 14\n" : "not ok 14\n";

my @all_country_names = $world->all_full_names;
print @all_country_names ? "ok 15\n" : "not ok 15\n";