aboutsummaryrefslogtreecommitdiffstats
path: root/t/100-increment-decrement.t
blob: 1345dfe3c20f01b203f4be399e60bbafa1f9eb4b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#!/usr/bin/env perl -w

use strict;

use Test::More;

use lib './';
use incdec;

is(
	incdec::incdec('test 12'),
	'test 13',
	'increments an integer'
);

is(
	incdec::incdec('test 12 0'),
	'test 13 0',
	'increments the first integer'
);

is(
	incdec::incdec('test 12 0', 6),
	'test 13 0',
	'increments the first integer with point at position 6'
);

is(
	incdec::incdec('test 19 0', 6),
	'test 20 0',
	'increments the first integer with point at position 6'
);

is(
	incdec::incdec('test 12 0', 7),
	'test 12 1',
	'increments the second integer with point at position 7'
);

is(
	incdec::incdec('test 12 19 555', 9),
	'test 12 20 555',
	'increments the second double-digit integer with point at position 9'
);

is(
	incdec::incdec('test 12 19 555', 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),
	'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),
	'test 12 19 555 65',
	'increments the fourth double-digit integer with point at position 16 backward'
);

is(
	incdec::incdec('test 12 19 555 64', 13, 1),
	'test 12 19 556 64',
	'increments the third triple-digit integer with point at position 13 backward'
);

done_testing;