diff options
author | Nicholas Clark <nick@ccl4.org> | 2009-10-02 11:46:30 +0100 |
---|---|---|
committer | Nicholas Clark <nick@ccl4.org> | 2009-10-02 11:46:30 +0100 |
commit | bdf43ffe6776e4e4c0d514386228a7b1ee6604ce (patch) | |
tree | 80f432cc0c9114f5528d3b1a2ccaf690a9ba0e0f /cpan/Locale-Codes/t/rename.t | |
parent | 55c474ba7687e845183c20351357b0cf4f16fdef (diff) | |
download | perl-bdf43ffe6776e4e4c0d514386228a7b1ee6604ce.tar.gz |
Move Locale::Codes from ext/ to cpan/
Diffstat (limited to 'cpan/Locale-Codes/t/rename.t')
-rw-r--r-- | cpan/Locale-Codes/t/rename.t | 79 |
1 files changed, 79 insertions, 0 deletions
diff --git a/cpan/Locale-Codes/t/rename.t b/cpan/Locale-Codes/t/rename.t new file mode 100644 index 0000000000..27f506c84b --- /dev/null +++ b/cpan/Locale-Codes/t/rename.t @@ -0,0 +1,79 @@ +#!./perl +# +# rename.t - tests for Locale::Country with "uk" aliases to "gb" +# + +use Locale::Country; + +local $SIG{__WARN__} = sub { }; # muffle warnings from carp + +Locale::Country::rename_country('gb' => 'Great Britain'); + +#----------------------------------------------------------------------- +# This is an array of tests. Each test is eval'd as an expression. +# If it evaluates to FALSE, then "not ok N" is printed for the test, +# otherwise "ok N". +#----------------------------------------------------------------------- +@TESTS = +( + #================================================ + # TESTS FOR code2country + #================================================ + + #---- selection of examples which should all result in undef ----------- + '!defined code2country()', # no argument + '!defined code2country(undef)', # undef argument + '!defined code2country("zz")', # illegal code + '!defined code2country("ja")', # should be jp for country + '!defined code2country("uk")', # code for United Kingdom is 'gb' + + #---- this call should return 0, since code doesn't exist -------------- + '!Locale::Country::rename_country("ukz", "United Karz")', + + #---- some successful examples ----------------------------------------- + 'code2country("BO") eq "Bolivia"', + 'code2country("pk") eq "Pakistan"', + 'code2country("sn") eq "Senegal"', + 'code2country("us") eq "United States"', + 'code2country("ad") eq "Andorra"', # first in DATA segment + 'code2country("zw") eq "Zimbabwe"', # last in DATA segment + 'code2country("gb") eq "Great Britain"', # normally "United Kingdom" + + #================================================ + # TESTS FOR country2code + #================================================ + + #---- selection of examples which should all result in undef ----------- + '!defined country2code()', # no argument + '!defined country2code(undef)', # undef argument + '!defined country2code("Banana")', # illegal country name + + #---- some successful examples ----------------------------------------- + 'country2code("japan") eq "jp"', + 'country2code("japan") ne "ja"', + 'country2code("Japan") eq "jp"', + 'country2code("United States") eq "us"', + + 'country2code("Great Britain") eq "gb"', + 'country2code("Great Britain", LOCALE_CODE_ALPHA_3) eq "gbr"', + 'country2code("Great Britain", LOCALE_CODE_NUMERIC) eq "826"', + + 'country2code("United Kingdom") eq "gb"', + 'country2code("United Kingdom", LOCALE_CODE_ALPHA_3) eq "gbr"', + 'country2code("United Kingdom", LOCALE_CODE_NUMERIC) eq "826"', + + 'country2code("Andorra") eq "ad"', # first in DATA segment + 'country2code("Zimbabwe") eq "zw"', # last in DATA segment +); + +print "1..", int(@TESTS), "\n"; + +$testid = 1; +foreach $test (@TESTS) +{ + eval "print (($test) ? \"ok $testid\\n\" : \"not ok $testid\\n\" )"; + print "not ok $testid\n" if $@; + ++$testid; +} + +exit 0; |