summaryrefslogtreecommitdiff
path: root/t/test_pl
diff options
context:
space:
mode:
authorBrad Gilbert <b2gills@gmail.com>2012-09-16 14:06:59 -0500
committerFather Chrysostomos <sprout@cpan.org>2012-09-25 14:35:12 -0700
commitf6e25e605fbd478eb79575b48accf888d57494e5 (patch)
tree21552ded1866f52ff641452d444ee3bf219a4110 /t/test_pl
parent48e9c5d48f9e8a882c41665cd4c18fb237fc00ac (diff)
downloadperl-f6e25e605fbd478eb79575b48accf888d57494e5.tar.gz
Add _num_to_alpha() to test.pl
Also added testing for _num_to_alpha()
Diffstat (limited to 't/test_pl')
-rw-r--r--t/test_pl/_num_to_alpha.t34
1 files changed, 34 insertions, 0 deletions
diff --git a/t/test_pl/_num_to_alpha.t b/t/test_pl/_num_to_alpha.t
new file mode 100644
index 0000000000..8897f05d37
--- /dev/null
+++ b/t/test_pl/_num_to_alpha.t
@@ -0,0 +1,34 @@
+#!./perl
+
+BEGIN {
+ chdir 't' if -d 't';
+ @INC = '../lib';
+ require './test.pl';
+}
+
+is( _num_to_alpha(-1), undef);
+is( _num_to_alpha( 0), 'A');
+is( _num_to_alpha( 1), 'B');
+
+is( _num_to_alpha(26 - 1), 'Z');
+is( _num_to_alpha(26 ), 'AA');
+is( _num_to_alpha(26 + 1), 'AB');
+
+is( _num_to_alpha(26 + 26 - 2), 'AY');
+is( _num_to_alpha(26 + 26 - 1), 'AZ');
+is( _num_to_alpha(26 + 26 ), 'BA');
+is( _num_to_alpha(26 + 26 + 1), 'BB');
+
+is( _num_to_alpha(26 ** 2 - 1), 'YZ');
+is( _num_to_alpha(26 ** 2 ), 'ZA');
+is( _num_to_alpha(26 ** 2 + 1), 'ZB');
+
+is( _num_to_alpha(26 ** 2 + 26 - 1), 'ZZ');
+is( _num_to_alpha(26 ** 2 + 26 ), 'AAA');
+is( _num_to_alpha(26 ** 2 + 26 + 1), 'AAB');
+
+is( _num_to_alpha(26 ** 3 + 26 ** 2 + 26 - 1 ), 'ZZZ');
+is( _num_to_alpha(26 ** 3 + 26 ** 2 + 26 ), 'AAAA');
+is( _num_to_alpha(26 ** 3 + 26 ** 2 + 26 + 1 ), 'AAAB');
+
+done_testing();