File: Tree-ipv4-and-6.t

package info (click to toggle)
libmaxmind-db-writer-perl 0.300003-5
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 1,336 kB
  • sloc: ansic: 3,059; perl: 2,895; makefile: 5; sh: 4
file content (36 lines) | stat: -rw-r--r-- 880 bytes parent folder | download | duplicates (3)
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
use strict;
use warnings;

use Test::Fatal;
use Test::More;

use MaxMind::DB::Writer::Tree;
use Net::Works::Network;

{
    my $tree = MaxMind::DB::Writer::Tree->new(
        ip_version            => 4,
        record_size           => 24,
        database_type         => 'Test',
        languages             => ['en'],
        description           => { en => 'Test tree' },
        map_key_type_callback => sub { },
    );

    my $expected
        = qr{You cannot insert an IPv6 address [(]::(?:0[.]0[.]0[.])?2[)] into an IPv4 tree.};

    like(
        exception { $tree->insert_network( '::2/128', 'foo' ) },
        $expected,
        q{Cannot insert an IPv6 network into an IPv4 tree}
    );

    like(
        exception { $tree->insert_range( '::2', '::3', 'foo' ) },
        $expected,
        q{Cannot insert an IPv6 range into an IPv4 tree}
    );
}

done_testing();