This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Added optional char limit to _num_to_alpha() in test.pl
[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
8is( _num_to_alpha(-1), undef);
9is( _num_to_alpha( 0), 'A');
10is( _num_to_alpha( 1), 'B');
11
12is( _num_to_alpha(26 - 1), 'Z');
13is( _num_to_alpha(26 ), 'AA');
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
25is( _num_to_alpha(26 ** 2 + 26 - 1), 'ZZ');
26is( _num_to_alpha(26 ** 2 + 26 ), 'AAA');
27is( _num_to_alpha(26 ** 2 + 26 + 1), 'AAB');
28
29is( _num_to_alpha(26 ** 3 + 26 ** 2 + 26 - 1 ), 'ZZZ');
30is( _num_to_alpha(26 ** 3 + 26 ** 2 + 26 ), 'AAAA');
31is( _num_to_alpha(26 ** 3 + 26 ** 2 + 26 + 1 ), 'AAAB');
32
2c36667f
BG
33is( _num_to_alpha(26 - 1 , 1), 'Z');
34is( _num_to_alpha(26 , 1), undef); # AA
35
36is( _num_to_alpha(26 ** 2 + 26 - 1 , 2 ), 'ZZ');
37is( _num_to_alpha(26 ** 2 + 26 , 2 ), undef); # AAA
38
39is( _num_to_alpha(26 ** 3 + 26 ** 2 + 26 - 1 , 3 ), 'ZZZ');
40is( _num_to_alpha(26 ** 3 + 26 ** 2 + 26 , 3 ), undef); # AAAA
41
f6e25e60 42done_testing();