File: v4-badnm.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 (42 lines) | stat: -rw-r--r-- 1,006 bytes parent folder | download | duplicates (5)
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
# I know this does not look like -*- perl -*-, but I swear it is...

use strict;
use Test::More;

$| = 1;

my @badnets = (
    '10.10.10.10/255.255.0.255',
    '10.10.10.10/255.0.255.255',
    '10.10.10.10/0.255.255.255',
    '10.10.10.10/128.255.0.255',
    '10.10.10.10/255.128.0.255',
    '10.10.10.10/255.255.255.129',
    '10.10.10.10/255.255.129.0',
    '10.10.10.10/255.255.255.130',
    '10.10.10.10/255.255.130.0',
    '10.10.10.10/255.0.0.1',
    '10.10.10.10/255.129.0.1',
    '10.10.10.10/0.255.0.255',
    '58.26.0.0-58.27.127.255',	# Taken from APNIC's WHOIS case
);

my @goodnets = ();

push @goodnets, "10.0.0.1/$_" for (0 .. 32);
push @goodnets, "10.0.0.1/255.255.255.255";

plan tests => 1 + @badnets + @goodnets;

die "# Cannot continue without NetAddr::IP::Lite\n"
    unless use_ok('NetAddr::IP::Lite');

my $count = 1;

ok(! defined NetAddr::IP::Lite->new($_), "new $_ should fail")
    for @badnets;

ok(defined NetAddr::IP::Lite->new($_), "new $_ should work")
    for @goodnets;