5 $runtests=shift(@ARGV);
6 if ( -f "t/testfunc.pl" ) {
7 require "t/testfunc.pl";
10 } elsif ( -f "testfunc.pl" ) {
11 require "testfunc.pl";
15 die "ERROR: cannot find testfunc.pl\n";
19 use Locale::Codes::Country;
21 %type = ( "LOCALE_CODE_ALPHA_2" => LOCALE_CODE_ALPHA_2,
22 "LOCALE_CODE_ALPHA_3" => LOCALE_CODE_ALPHA_3,
23 "LOCALE_CODE_NUMERIC" => LOCALE_CODE_NUMERIC,
24 "LOCALE_CODE_FIPS" => LOCALE_CODE_FIPS,
30 if ($test[0] eq "rename_country") {
32 $test[2] = $type{$test[2]}
33 if (@test == 3 && $test[2] && exists $type{$test[2]});
34 return Locale::Codes::Country::rename_country(@test,"nowarn");
36 } elsif ($test[0] eq "add_country") {
38 $test[2] = $type{$test[2]}
39 if (@test == 3 && $test[2] && exists $type{$test[2]});
40 return Locale::Codes::Country::add_country(@test,"nowarn");
42 } elsif ($test[0] eq "delete_country") {
44 $test[1] = $type{$test[1]}
45 if (@test == 2 && $test[1] && exists $type{$test[1]});
46 return Locale::Codes::Country::delete_country(@test,"nowarn");
48 } elsif ($test[0] eq "add_country_alias") {
50 return Locale::Codes::Country::add_country_alias(@test,"nowarn");
52 } elsif ($test[0] eq "delete_country_alias") {
54 return Locale::Codes::Country::delete_country_alias(@test,"nowarn");
56 } elsif ($test[0] eq "rename_country_code") {
58 $test[2] = $type{$test[2]}
59 if (@test == 3 && $test[2] && exists $type{$test[2]});
60 return Locale::Codes::Country::rename_country_code(@test,"nowarn");
62 } elsif ($test[0] eq "add_country_code_alias") {
64 $test[2] = $type{$test[2]}
65 if (@test == 3 && $test[2] && exists $type{$test[2]});
66 return Locale::Codes::Country::add_country_code_alias(@test,"nowarn");
68 } elsif ($test[0] eq "delete_country_code_alias") {
70 $test[1] = $type{$test[1]}
71 if (@test == 2 && $test[1] && exists $type{$test[1]});
72 return Locale::Codes::Country::delete_country_code_alias(@test,"nowarn");
74 } elsif ($test[0] eq "country2code") {
76 $test[1] = $type{$test[1]}
77 if (@test == 2 && $test[1] && exists $type{$test[1]});
78 return country2code(@test);
81 shift(@test) if ($test[0] eq "code2country");
82 $test[1] = $type{$test[1]}
83 if (@test == 2 && $test[1] && exists $type{$test[1]});
84 return code2country(@test);
90 ###################################
97 rename_country x1 NewName ~ 0
99 rename_country gb NewName LOCALE_CODE_FOO ~ 0
101 rename_country gb Macao ~ 0
103 rename_country gb NewName LOCALE_CODE_ALPHA_3 ~ 0
109 rename_country gb NewName ~ 1
115 ###################################
120 add_country xx Bolivia ~ 0
122 add_country fi Xxxxx ~ 0
124 add_country xx Xxxxx ~ 1
128 ###################################
129 # Test add_country_alias
131 add_country_alias FooBar NewName ~ 0
133 add_country_alias Australia Angola ~ 0
135 country2code Australia ~ au
137 country2code DownUnder ~ _undef_
139 add_country_alias Australia DownUnder ~ 1
141 country2code DownUnder ~ au
143 ###################################
144 # Test delete_country_alias
148 delete_country_alias Foobar ~ 0
150 delete_country_alias UK ~ 1
152 country2code uk ~ _undef_
154 delete_country_alias Angola ~ 0
156 ###################################
157 # Test delete_country
159 country2code Angola ~ ao
161 country2code Angola LOCALE_CODE_ALPHA_3 ~ ago
163 delete_country ao ~ 1
165 country2code Angola ~ _undef_
167 country2code Angola LOCALE_CODE_ALPHA_3 ~ ago
169 ###################################
170 # Test rename_country_code
172 code2country zz ~ _undef_
174 code2country ar ~ Argentina
176 country2code Argentina ~ ar
178 rename_country_code ar us ~ 0
180 rename_country_code ar zz ~ 1
182 rename_country_code us ar ~ 0
184 code2country zz ~ Argentina
186 code2country ar ~ Argentina
188 country2code Argentina ~ zz
190 rename_country_code zz ar ~ 1
192 code2country zz ~ Argentina
194 code2country ar ~ Argentina
196 country2code Argentina ~ ar
198 ###################################
199 # Test add_country_code_alias and
200 # delete_country_code_alias
202 code2country bm ~ Bermuda
204 code2country yy ~ _undef_
206 country2code Bermuda ~ bm
208 add_country_code_alias bm us ~ 0
210 add_country_code_alias bm zz ~ 0
212 add_country_code_alias bm yy ~ 1
214 code2country bm ~ Bermuda
216 code2country yy ~ Bermuda
218 country2code Bermuda ~ bm
220 delete_country_code_alias us ~ 0
222 delete_country_code_alias ww ~ 0
224 delete_country_code_alias yy ~ 1
226 code2country bm ~ Bermuda
228 code2country yy ~ _undef_
230 country2code Bermuda ~ bm
234 print "country (semi-private)...\n";
235 test_Func(\&test,$tests,$runtests);
240 # indent-tabs-mode: nil
241 # cperl-indent-level: 3
242 # cperl-continued-statement-offset: 2
243 # cperl-continued-brace-offset: 0
244 # cperl-brace-offset: 0
245 # cperl-brace-imaginary-offset: 0
246 # cperl-label-offset: -2