From f6e25e605fbd478eb79575b48accf888d57494e5 Mon Sep 17 00:00:00 2001 From: Brad Gilbert Date: Sun, 16 Sep 2012 14:06:59 -0500 Subject: Add _num_to_alpha() to test.pl Also added testing for _num_to_alpha() --- t/test_pl/_num_to_alpha.t | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 t/test_pl/_num_to_alpha.t (limited to 't/test_pl') 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(); -- cgit v1.2.1