diff options
Diffstat (limited to 't')
| -rw-r--r-- | t/100-increment-decrement.t | 219 | 
1 files changed, 138 insertions, 81 deletions
| diff --git a/t/100-increment-decrement.t b/t/100-increment-decrement.t index 6fada9b..4b7d1a7 100644 --- a/t/100-increment-decrement.t +++ b/t/100-increment-decrement.t @@ -25,165 +25,222 @@ use Test::More;  use lib './';  use incdec; -is( -	incdec::incdec('test 12', 1), -	'test 13', +my @want; +my @got; + +@want = incdec::incdec('test 12', 1); +@got = ('test 13', 5); +is_deeply( +	\@want, +	\@got,  	'increments an integer'  ); -is( -	incdec::incdec('test 12 0', 1), -	'test 13 0', +@want = incdec::incdec('test 12 0', 1); +@got = ('test 13 0', 5); +is_deeply( +	\@want, +	\@got,  	'increments the first integer'  ); -is( -	incdec::incdec('test 12 0', 1, 6), -	'test 13 0', +@want = incdec::incdec('test 12 0', 1, 6); +@got = ('test 13 0', 5); +is_deeply( +	\@want, +	\@got,  	'increments the first integer with point at position 6'  ); -is( -	incdec::incdec('test 19 0', 1, 6), -	'test 20 0', +@want = incdec::incdec('test 19 0', 1, 6); +@got = ('test 20 0', 5); +is_deeply( +	\@want, +	\@got,  	'increments the first integer with point at position 6'  ); -is( -	incdec::incdec('test 12 0', 1, 7), -	'test 12 1', +@want = incdec::incdec('test 12 0', 1, 7); +@got = ('test 12 1', 8); +is_deeply( +	\@want, +	\@got,  	'increments the second integer with point at position 7'  ); -is( -	incdec::incdec('test 12 19 555', 1, 9), -	'test 12 20 555', +@want = incdec::incdec('test 12 19 555', 1, 9); +@got = ('test 12 20 555', 8); +is_deeply( +	\@want, +	\@got,  	'increments the second double-digit integer with point at position 9'  ); -is( -	incdec::incdec('test 12 19 555', 1, 12), -	'test 12 19 556', +@want = incdec::incdec('test 12 19 555', 1, 12); +@got = ('test 12 19 556', 11); +is_deeply( +	\@want, +	\@got,  	'increments the third triple-digit integer with point at position 12'  ); -is( -	incdec::incdec('test 12 19 555', 7, 9), -	'test 12 26 555', +@want = incdec::incdec('test 12 19 555', 7, 9); +@got = ('test 12 26 555', 8); +is_deeply( +	\@want, +	\@got,  	'increments the second double-digit integer by 7 with point at position 9'  ); -is( -	incdec::incdec('test 12 19 555 64', 1, 16), -	'test 12 19 555 65', +@want = incdec::incdec('test 12 19 555 64', 1, 16); +@got = ('test 12 19 555 65', 15); +is_deeply( +	\@want, +	\@got,  	'increments the fourth double-digit integer with point at position 16'  ); -is( -	incdec::incdec('test 12 19 555 64', 1, 17, 1), -	'test 12 19 555 65', +@want = incdec::incdec('test 12 19 555 64', 1, 17, 1); +@got = ('test 12 19 555 65', 15); +is_deeply( +	\@want, +	\@got,  	'increments the fourth double-digit integer with point at position 17 backward'  ); -is( -	incdec::incdec('test 12 19 555 64', 1, 13, 1), -	'test 12 19 556 64', +@want = incdec::incdec('test 12 19 555 64', 1, 13, 1); +@got = ('test 12 19 556 64', 11); +is_deeply( +	\@want, +	\@got,  	'increments the third triple-digit integer with point at position 13 backward'  ); -is( -	incdec::incdec('test 12 19 555 64', 1, 14, 1), -	'test 12 19 556 64', +@want = incdec::incdec('test 12 19 555 64', 1, 14, 1); +@got = ('test 12 19 556 64', 11); +is_deeply( +	\@want, +	\@got,  	'increments the third triple-digit integer with point at position 14 backward'  ); -is( -	incdec::incdec('test 12 982 4 ', 1, 14, 1), -	'test 12 982 5 ', +@want = incdec::incdec('test 12 982 4 ', 1, 14, 1); +@got = ('test 12 982 5 ', 12); +is_deeply( +	\@want, +	\@got,  	'increments the third integer with point at position 14 backward'  ); -is( -	incdec::incdec('test -1 ', 1, 7, 1), -	'test 0 ', +@want = incdec::incdec('test -1 ', 1, 7, 1); +@got = ('test 0 ', 5); +is_deeply( +	\@want, +	\@got,  	'increments the negative integer with point at position 7 backward'  ); -is( -	incdec::incdec('test -1 ', -1, 7, 1), -	'test -2 ', +@want = incdec::incdec('test -1 ', -1, 7, 1); +@got = ('test -2 ', 5); +is_deeply( +	\@want, +	\@got,  	'decrements the negative integer with point at position 7 backward'  ); -is( -	incdec::incdec('test 1 -2', 1, 8, 1), -	'test 1 -1', +@want = incdec::incdec('test 1 -2', 1, 8, 1); +@got = ('test 1 -1', 7); +is_deeply( +	\@want, +	\@got,  	'increments the second negative integer with point at position 8 backward'  ); -is( -	incdec::incdec('test 1 -2', -1, 8, 1), -	'test 1 -3', +@want = incdec::incdec('test 1 -2', -1, 8, 1); +@got = ('test 1 -3', 7); +is_deeply( +	\@want, +	\@got,  	'decrements the second negative integer with point at position 8 backward'  ); -is( -	incdec::incdec('test 12', -1), -	'test 11', +@want = incdec::incdec('test 12', -1); +@got = ('test 11', 5); +is_deeply( +	\@want, +	\@got,  	'decrements the first integer'  ); -is( -	incdec::incdec('test 12', -1, 7, 1), -	'test 11', +@want = incdec::incdec('test 12', -1, 7, 1); +@got = ('test 11', 5); +is_deeply( +	\@want, +	\@got,  	'decrements the first integer with point at position 7 backward'  ); -is( -	incdec::incdec('test 12 982 4', -1, 11, 1), -	'test 12 981 4', +@want = incdec::incdec('test 12 982 4', -1, 11, 1); +@got = ('test 12 981 4', 8); +is_deeply( +	\@want, +	\@got,  	'decrements the second integer with point at position 11 backward'  ); -is( -	incdec::incdec('test 12 982 4', -1, 9, 1), -	'test 12 981 4', +@want = incdec::incdec('test 12 982 4', -1, 9, 1); +@got = ('test 12 981 4', 8); +is_deeply( +	\@want, +	\@got,  	'decrements the second integer with point at position 9 backward'  ); -is( -	incdec::incdec('test 12 982 4', -5, 8, 1), -	'test 12 977 4', +@want = incdec::incdec('test 12 982 4', -5, 8, 1); +@got = ('test 12 977 4', 8); +is_deeply( +	\@want, +	\@got,  	'decrements the second integer by 5 with point at position 8 backward'  ); -is( -	incdec::incdec('test 12 1 4', -2, 9, 1), -	'test 12 -1 4', +@want = incdec::incdec('test 12 1 4', -2, 9, 1); +@got = ('test 12 -1 4', 8); +is_deeply( +	\@want, +	\@got,  	'decrements the second integer by 2 with point at position 9 backward'  ); -is( -	incdec::incdec("sed -n '39,54p' Alice\'s\ Adventures\ in\ Wonderland.txt ", 1, 3, 1), -	"sed -n '40,54p' Alice\'s\ Adventures\ in\ Wonderland.txt ", +@want = incdec::incdec("sed -n '39,54p' Alice\'s\ Adventures\ in\ Wonderland.txt ", 1, 3, 1); +@got = ("sed -n '40,54p' Alice\'s\ Adventures\ in\ Wonderland.txt ", 0); +is_deeply( +	\@want, +	\@got,  	'increments the first integer with point at position 3 backward'  ); -is( -	incdec::incdec("sed -n '39,54p' Alice\'s\ Adventures\ in\ Wonderland.txt ", 1, 8, 1), -	"sed -n '40,54p' Alice\'s\ Adventures\ in\ Wonderland.txt ", +@want = incdec::incdec("sed -n '39,54p' Alice\'s\ Adventures\ in\ Wonderland.txt ", 1, 8, 1); +@got = ("sed -n '40,54p' Alice\'s\ Adventures\ in\ Wonderland.txt ", 8); +is_deeply( +	\@want, +	\@got,  	'increments the first integer with point at position 8 backward'  ); -is( -	incdec::incdec("sed -n '39,54p' Alice\'s\ Adventures\ in\ Wonderland.txt ", -1, 10, 1), -	"sed -n '38,54p' Alice\'s\ Adventures\ in\ Wonderland.txt ", +@want = incdec::incdec("sed -n '39,54p' Alice\'s\ Adventures\ in\ Wonderland.txt ", -1, 10, 1); +@got = ("sed -n '38,54p' Alice\'s\ Adventures\ in\ Wonderland.txt ", 8); +is_deeply( +	\@want, +	\@got,  	'decrements the first integer with point at position 10 backward'  ); -is( -	incdec::incdec("sed -n '39,54p' Alice\'s\ Adventures\ in\ Wonderland.txt ", 1, 3, 0), -	"sed -n '40,54p' Alice\'s\ Adventures\ in\ Wonderland.txt ", +@want = incdec::incdec("sed -n '39,54p' Alice\'s\ Adventures\ in\ Wonderland.txt ", 1, 3, 0); +@got = ("sed -n '40,54p' Alice\'s\ Adventures\ in\ Wonderland.txt ", 8); +is_deeply( +	\@want, +	\@got,  	'increments the first integer with point at position 3'  ); | 
