Commit | Line | Data |
917211f5 |
1 | #!./perl |
2 | # |
3 | # rename.t - tests for Locale::Country with "uk" aliases to "gb" |
4 | # |
5 | |
6 | use Locale::Country; |
7 | |
8 | local $SIG{__WARN__} = sub { }; # muffle warnings from carp |
9 | |
10 | Locale::Country::rename_country('gb' => 'Great Britain'); |
11 | |
12 | #----------------------------------------------------------------------- |
13 | # This is an array of tests. Each test is eval'd as an expression. |
14 | # If it evaluates to FALSE, then "not ok N" is printed for the test, |
15 | # otherwise "ok N". |
16 | #----------------------------------------------------------------------- |
17 | @TESTS = |
18 | ( |
19 | #================================================ |
20 | # TESTS FOR code2country |
21 | #================================================ |
22 | |
23 | #---- selection of examples which should all result in undef ----------- |
24 | '!defined code2country()', # no argument |
25 | '!defined code2country(undef)', # undef argument |
26 | '!defined code2country("zz")', # illegal code |
27 | '!defined code2country("ja")', # should be jp for country |
28 | '!defined code2country("uk")', # code for United Kingdom is 'gb' |
29 | |
30 | #---- this call should return 0, since code doesn't exist -------------- |
31 | '!Locale::Country::rename_country("ukz", "United Karz")', |
32 | |
33 | #---- some successful examples ----------------------------------------- |
34 | 'code2country("BO") eq "Bolivia"', |
35 | 'code2country("pk") eq "Pakistan"', |
36 | 'code2country("sn") eq "Senegal"', |
37 | 'code2country("us") eq "United States"', |
38 | 'code2country("ad") eq "Andorra"', # first in DATA segment |
39 | 'code2country("zw") eq "Zimbabwe"', # last in DATA segment |
40 | 'code2country("gb") eq "Great Britain"', # normally "United Kingdom" |
41 | |
42 | #================================================ |
43 | # TESTS FOR country2code |
44 | #================================================ |
45 | |
46 | #---- selection of examples which should all result in undef ----------- |
47 | '!defined country2code()', # no argument |
48 | '!defined country2code(undef)', # undef argument |
49 | '!defined country2code("Banana")', # illegal country name |
50 | |
51 | #---- some successful examples ----------------------------------------- |
52 | 'country2code("japan") eq "jp"', |
53 | 'country2code("japan") ne "ja"', |
54 | 'country2code("Japan") eq "jp"', |
55 | 'country2code("United States") eq "us"', |
56 | |
57 | 'country2code("Great Britain") eq "gb"', |
58 | 'country2code("Great Britain", LOCALE_CODE_ALPHA_3) eq "gbr"', |
59 | 'country2code("Great Britain", LOCALE_CODE_NUMERIC) eq "826"', |
60 | |
61 | 'country2code("United Kingdom") eq "gb"', |
62 | 'country2code("United Kingdom", LOCALE_CODE_ALPHA_3) eq "gbr"', |
63 | 'country2code("United Kingdom", LOCALE_CODE_NUMERIC) eq "826"', |
64 | |
65 | 'country2code("Andorra") eq "ad"', # first in DATA segment |
66 | 'country2code("Zimbabwe") eq "zw"', # last in DATA segment |
67 | ); |
68 | |
69 | print "1..", int(@TESTS), "\n"; |
70 | |
71 | $testid = 1; |
72 | foreach $test (@TESTS) |
73 | { |
74 | eval "print (($test) ? \"ok $testid\\n\" : \"not ok $testid\\n\" )"; |
75 | print "not ok $testid\n" if $@; |
76 | ++$testid; |
77 | } |
78 | |
79 | exit 0; |