File: over_math.t

package info (click to toggle)
libnetaddr-ip-perl 4.028%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 1,048 kB
  • ctags: 101
  • sloc: perl: 850; ansic: 90; pascal: 78; sh: 48; makefile: 8
file content (64 lines) | stat: -rw-r--r-- 1,001 bytes parent folder | download | duplicates (6)
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

#use diagnostics;
use NetAddr::IP::Lite;

$| = 1;

print "1..7\n";

my $test = 1;
sub ok() {
  print 'ok ',$test++,"\n";
}

my $ip	= new NetAddr::IP::Lite('0.0.0.4/24');

## test '+'
my $exp = '0.0.0.132/24';
my $nip = $ip + 128;
print 'got: ',$nip," exp: $exp\nnot "
	unless $nip eq $exp;
&ok;

## test '+' wrap around
$nip = $ip + 257;
$exp = '0.0.0.5/24';
print 'got: ',$nip," exp: $exp\nnot "
	unless $nip eq $exp;
&ok;

## test '-' and wrap
$nip = $ip - 10;
$exp = '0.0.0.250/24';
print 'got: ',$nip," exp: $exp\nnot "
	unless $nip eq $exp;
&ok;

## test '++' post
$nip++;
$exp = '0.0.0.251/24';
print 'got: ',$nip," exp: $exp\nnot "
	unless $nip eq $exp;
&ok;

## test '++' pre
++$nip;
$exp = '0.0.0.252/24';
print 'got: ',$nip," exp: $exp\nnot "
	unless $nip eq $exp;
&ok;

## test '--' post
$ip--;
$exp = '0.0.0.3/24';
print 'got: ',$ip," exp: $exp\nnot "
	unless $ip eq $exp;
&ok;

## test '--' pre
--$ip;
$exp = '0.0.0.2/24';
print 'got: ',$ip," exp: $exp\nnot "
	unless $ip eq $exp;
&ok;