line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# $Id: loops.t,v 1.2 2006/08/16 19:17:01 lem Exp $ |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
use Test::More; |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
my @deltas = (0, 1, 2, 3, 255); |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
plan tests => 16 + @deltas; |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
use_ok('NetAddr::IP'); |
10
|
|
|
|
|
|
|
my $count = 1; |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
for (my $ip = new NetAddr::IP '10.0.0.1/28'; |
13
|
|
|
|
|
|
|
$ip < $ip->broadcast; |
14
|
|
|
|
|
|
|
$ip ++) |
15
|
|
|
|
|
|
|
{ |
16
|
|
|
|
|
|
|
my $o = $ip->addr; |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
$o =~ s/^.+\.(\d+)$/$1/; |
19
|
|
|
|
|
|
|
is($o, $count, "Correct octet for " . $ip); |
20
|
|
|
|
|
|
|
++ $count; |
21
|
|
|
|
|
|
|
} |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
my $ip = new NetAddr::IP '10.0.0.255/24'; |
24
|
|
|
|
|
|
|
$ip ++; |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
is($ip, '10.0.0.0/24', "Correct mask wraparound"); |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
$ip = new NetAddr::IP '10.0.0.0/24'; |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
for my $v (@deltas) { |
31
|
|
|
|
|
|
|
my $target = '10.0.0.' . $v . '/24'; |
32
|
|
|
|
|
|
|
is($ip + $v, '10.0.0.' . $v . '/24', "$ip + $v vs $target"); |
33
|
|
|
|
|
|
|
} |