This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
perldelta - move split change to other perlfunc changes and add issue link
[perl5.git] / t / test_pl / _num_to_alpha.t
CommitLineData
f6e25e60
BG
1#!./perl
2
3BEGIN {
4 chdir 't' if -d 't';
f6e25e60
BG
5 require './test.pl';
6}
7
a087e815
BG
8is( _num_to_alpha(-1), undef, 'Returns undef for negative numbers');
9is( _num_to_alpha( 0), 'A', "Starts at 'A'");
f6e25e60
BG
10is( _num_to_alpha( 1), 'B');
11
a087e815
BG
12is( _num_to_alpha(26 - 1), 'Z', 'Last single letter return value');
13is( _num_to_alpha(26 ), 'AA', 'First double letter return value');
f6e25e60
BG
14is( _num_to_alpha(26 + 1), 'AB');
15
16is( _num_to_alpha(26 + 26 - 2), 'AY');
17is( _num_to_alpha(26 + 26 - 1), 'AZ');
18is( _num_to_alpha(26 + 26 ), 'BA');
19is( _num_to_alpha(26 + 26 + 1), 'BB');
20
21is( _num_to_alpha(26 ** 2 - 1), 'YZ');
22is( _num_to_alpha(26 ** 2 ), 'ZA');
23is( _num_to_alpha(26 ** 2 + 1), 'ZB');
24
a087e815
BG
25is( _num_to_alpha(26 ** 2 + 26 - 1), 'ZZ', 'Last double letter return value');
26is( _num_to_alpha(26 ** 2 + 26 ), 'AAA', 'First triple letter return value');
f6e25e60
BG
27is( _num_to_alpha(26 ** 2 + 26 + 1), 'AAB');
28
a087e815
BG
29is( _num_to_alpha(26 ** 3 + 26 ** 2 + 26 - 1 ), 'ZZZ', 'Last triple letter return value');
30is( _num_to_alpha(26 ** 3 + 26 ** 2 + 26 ), 'AAAA', 'First quadruple letter return value');
f6e25e60
BG
31is( _num_to_alpha(26 ** 3 + 26 ** 2 + 26 + 1 ), 'AAAB');
32
a087e815
BG
33note('Testing limit capabilities');
34
35is( _num_to_alpha(26 - 1 , 1), 'Z', 'Largest return value for one letter');
2c36667f
BG
36is( _num_to_alpha(26 , 1), undef); # AA
37
a087e815 38is( _num_to_alpha(26 ** 2 + 26 - 1 , 2 ), 'ZZ', 'Largest return value for two letters');
2c36667f
BG
39is( _num_to_alpha(26 ** 2 + 26 , 2 ), undef); # AAA
40
a087e815 41is( _num_to_alpha(26 ** 3 + 26 ** 2 + 26 - 1 , 3 ), 'ZZZ', 'Largest return value for three letters');
2c36667f
BG
42is( _num_to_alpha(26 ** 3 + 26 ** 2 + 26 , 3 ), undef); # AAAA
43
f6e25e60 44done_testing();