1
2#use diagnostics;
3use NetAddr::IP::Lite;
4
5$| = 1;
6
7print "1..7\n";
8
9my $test = 1;
10sub ok() {
11  print 'ok ',$test++,"\n";
12}
13
14my $ip	= new NetAddr::IP::Lite('0.0.0.4/24');
15
16## test '+'
17my $exp = '0.0.0.132/24';
18my $nip = $ip + 128;
19print 'got: ',$nip," exp: $exp\nnot "
20	unless $nip eq $exp;
21&ok;
22
23## test '+' wrap around
24$nip = $ip + 257;
25$exp = '0.0.0.5/24';
26print 'got: ',$nip," exp: $exp\nnot "
27	unless $nip eq $exp;
28&ok;
29
30## test '-' and wrap
31$nip = $ip - 10;
32$exp = '0.0.0.250/24';
33print 'got: ',$nip," exp: $exp\nnot "
34	unless $nip eq $exp;
35&ok;
36
37## test '++' post
38$nip++;
39$exp = '0.0.0.251/24';
40print 'got: ',$nip," exp: $exp\nnot "
41	unless $nip eq $exp;
42&ok;
43
44## test '++' pre
45++$nip;
46$exp = '0.0.0.252/24';
47print 'got: ',$nip," exp: $exp\nnot "
48	unless $nip eq $exp;
49&ok;
50
51## test '--' post
52$ip--;
53$exp = '0.0.0.3/24';
54print 'got: ',$ip," exp: $exp\nnot "
55	unless $ip eq $exp;
56&ok;
57
58## test '--' pre
59--$ip;
60$exp = '0.0.0.2/24';
61print 'got: ',$ip," exp: $exp\nnot "
62	unless $ip eq $exp;
63&ok;
64
65