aboutsummaryrefslogtreecommitdiffstats
path: root/t
diff options
context:
space:
mode:
authorTeddy Wing2021-08-19 21:57:59 +0200
committerTeddy Wing2021-08-19 21:57:59 +0200
commit016240388e39c58b2d0bba118e4c1a1a52011cee (patch)
tree5a1d66648259ace1179df0dae0ee97c123c4be18 /t
parent463490a1857274ebf5b488c38e1a280a4d9b7669 (diff)
downloadreadline-incdec-016240388e39c58b2d0bba118e4c1a1a52011cee.tar.bz2
incdec: Add increment step argument
A new subrouting argument that defines by how much the number should be incremented, or decremented if a negative step value is given. Add a few new tests to verify the decrementing behaviour. The final test where point is in the middle of the number fails.
Diffstat (limited to 't')
-rw-r--r--t/100-increment-decrement.t46
1 files changed, 35 insertions, 11 deletions
diff --git a/t/100-increment-decrement.t b/t/100-increment-decrement.t
index 73cfdab..4af73d5 100644
--- a/t/100-increment-decrement.t
+++ b/t/100-increment-decrement.t
@@ -8,69 +8,93 @@ use lib './';
use incdec;
is(
- incdec::incdec('test 12'),
+ incdec::incdec('test 12', 1),
'test 13',
'increments an integer'
);
is(
- incdec::incdec('test 12 0'),
+ incdec::incdec('test 12 0', 1),
'test 13 0',
'increments the first integer'
);
is(
- incdec::incdec('test 12 0', 6),
+ incdec::incdec('test 12 0', 1, 6),
'test 13 0',
'increments the first integer with point at position 6'
);
is(
- incdec::incdec('test 19 0', 6),
+ incdec::incdec('test 19 0', 1, 6),
'test 20 0',
'increments the first integer with point at position 6'
);
is(
- incdec::incdec('test 12 0', 7),
+ incdec::incdec('test 12 0', 1, 7),
'test 12 1',
'increments the second integer with point at position 7'
);
is(
- incdec::incdec('test 12 19 555', 9),
+ incdec::incdec('test 12 19 555', 1, 9),
'test 12 20 555',
'increments the second double-digit integer with point at position 9'
);
is(
- incdec::incdec('test 12 19 555', 12),
+ incdec::incdec('test 12 19 555', 1, 12),
'test 12 19 556',
'increments the third triple-digit integer with point at position 12'
);
is(
- incdec::incdec('test 12 19 555 64', 16),
+ incdec::incdec('test 12 19 555 64', 1, 16),
'test 12 19 555 65',
'increments the fourth double-digit integer with point at position 16'
);
is(
- incdec::incdec('test 12 19 555 64', 17, 1),
+ incdec::incdec('test 12 19 555 64', 1, 17, 1),
'test 12 19 555 65',
'increments the fourth double-digit integer with point at position 17 backward'
);
is(
- incdec::incdec('test 12 19 555 64', 13, 1),
+ incdec::incdec('test 12 19 555 64', 1, 13, 1),
'test 12 19 556 64',
'increments the third triple-digit integer with point at position 13 backward'
);
is(
- incdec::incdec('test 12 19 555 64', 14, 1),
+ incdec::incdec('test 12 19 555 64', 1, 14, 1),
'test 12 19 556 64',
'increments the third triple-digit integer with point at position 14 backward'
);
+is(
+ incdec::incdec('test 12', -1),
+ 'test 11',
+ 'decrements the first integer'
+);
+
+is(
+ incdec::incdec('test 12', -1, 7, 1),
+ 'test 11',
+ 'decrements the first integer with point at position 7 backward'
+);
+
+is(
+ incdec::incdec('test 12 982 4', -1, 11, 1),
+ 'test 12 981 4',
+ 'decrements the second integer with point at position 11 backward'
+);
+
+is(
+ incdec::incdec('test 12 982 4', -1, 9, 1),
+ 'test 12 981 4',
+ 'decrements the second integer with point at position 9 backward'
+);
+
done_testing;