summaryrefslogtreecommitdiff
path: root/lib/Locale/Codes/t/currency.t
blob: 55a04db9fbdd07da9e5a16d2a6d8a1db56cd6706 (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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#!./perl
#
# currency.t - tests for Locale::Currency
#

BEGIN {
        chdir 't' if -d 't';
        @INC = '../lib';
}

use Locale::Currency;

#-----------------------------------------------------------------------
# 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 code2currency
	#================================================

 #---- selection of examples which should all result in undef -----------
 '!defined code2currency()',                 # no argument => undef returned
 '!defined code2currency(undef)',            # undef arg   => undef returned
 '!defined code2currency("zz")',             # illegal code => undef
 '!defined code2currency("zzzz")',           # illegal code => undef
 '!defined code2currency("zzz")',            # illegal code => undef
 '!defined code2currency("ukp")',            # gbp for sterling, not ukp

 #---- misc tests -------------------------------------------------------
 'code2currency("all") eq "Lek"',
 'code2currency("ats") eq "Schilling"',
 'code2currency("bob") eq "Boliviano"',
 'code2currency("bnd") eq "Brunei Dollar"',
 'code2currency("cop") eq "Colombian Peso"',
 'code2currency("dkk") eq "Danish Krone"',
 'code2currency("fjd") eq "Fiji Dollar"',
 'code2currency("idr") eq "Rupiah"',
 'code2currency("chf") eq "Swiss Franc"',
 'code2currency("mvr") eq "Rufiyaa"',
 'code2currency("mmk") eq "Kyat"',
 'code2currency("mwk") eq "Kwacha"',	# two different codes for Kwacha
 'code2currency("zmk") eq "Kwacha"',    # used in Zambia and Malawi
 'code2currency("byr") eq "Belarussian Ruble"',	# 2 codes for belarussian ruble
 'code2currency("byb") eq "Belarussian Ruble"', #
 'code2currency("rub") eq "Russian Ruble"',	# 2 codes for russian ruble
 'code2currency("rur") eq "Russian Ruble"',     #

 #---- some successful examples -----------------------------------------
 'code2currency("BOB") eq "Boliviano"',
 'code2currency("adp") eq "Andorran Peseta"',  # first in DATA segment
 'code2currency("zwd") eq "Zimbabwe Dollar"',  # last in DATA segment

	#================================================
	# TESTS FOR currency2code
	#================================================

 #---- selection of examples which should all result in undef -----------
 '!defined currency2code()',                 # no argument => undef returned
 '!defined currency2code(undef)',            # undef arg   => undef returned
 '!defined currency2code("")',               # empty string => undef returned
 '!defined currency2code("Banana")',         # illegal curr name => undef

 #---- some successful examples -----------------------------------------
 'currency2code("Kroon")           eq "eek"',
 'currency2code("Markka")         eq "fim"',
 'currency2code("Riel")            eq "khr"',
 'currency2code("PULA")            eq "bwp"',
 'currency2code("Andorran Peseta") eq "adp"',       # first in DATA segment
 'currency2code("Zimbabwe Dollar") eq "zwd"',       # 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;