File: operations.t

package info (click to toggle)
libnet-cidr-set-perl 0.19-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 292 kB
  • sloc: perl: 1,116; makefile: 2
file content (24 lines) | stat: -rw-r--r-- 721 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
#!perl

use strict;
use warnings;
use Test::More tests => 4;
use Net::CIDR::Set;
use Data::Dumper;

{
  my $s1 = Net::CIDR::Set->new( '0.0.0.0-0.0.0.255',
    '0.0.2.0-255.255.255.255' );
  my $s2 = Net::CIDR::Set->new( '0.0.1.0-0.0.1.255' );
  my $s3 = $s1->union( $s2 );
  is_deeply [ $s3->as_cidr_array ], ['0.0.0.0/0'], 'union';
  my $s4 = $s1->intersection( $s2 );
  is_deeply [ $s4->as_cidr_array ], [], 'intersection';
  my $s5 = $s1->complement->union( $s2->complement->union );
  is_deeply [ $s5->as_cidr_array ], ['0.0.0.0/0'], 'complement + union';
  my $s6 = $s1->complement->intersection( $s2->complement );
  is_deeply [ $s6->as_cidr_array ], [], 'complement + intersection';
}

# vim:ts=2:sw=2:et:ft=perl