File: 01-core.t

package info (click to toggle)
libdomain-publicsuffix-perl 0.21-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 536 kB
  • sloc: perl: 14,272; makefile: 2
file content (42 lines) | stat: -rwxr-xr-x 1,813 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
#!/usr/bin/env perl
use strict;
use warnings;
use Test::More;
BEGIN { use_ok('Domain::PublicSuffix') };

my $ps = Domain::PublicSuffix->new();

is( ref($ps), 'Domain::PublicSuffix',                       , 'create-object' );
is( $ps->get_root_domain('google.com'), 'google.com'        , 'root-to-root-com' );
is( $ps->tld(), 'com',                                      , 'root-to-root-com-tld' );

is( $ps->get_root_domain('www.google.com'), 'google.com'    , 'www-to-root-com' );
is( $ps->tld(), 'com',                                      , 'root-to-root-com-tld' );

is( $ps->get_root_domain('www.google.co.uk'), 'google.co.uk', 'www-to-root-co-uk' );
is( $ps->tld(), 'uk',                                       , 'root-to-root-co-uk-tld' );
is( $ps->suffix(), 'co.uk',                                 , 'root-to-root-co-uk-etld' );

is( $ps->get_root_domain('www.0.com'), '0.com'              , '0.com' );
is( $ps->tld(), 'com',                                      , '0.com-tld' );

is( $ps->get_root_domain('not_valid_at_all'), undef         , 'invalid-domain' );
is( $ps->error, 'Malformed domain',                         , 'domain-error' );

$ps = Domain::PublicSuffix->new({ 'use_default' => 1 });

is( ref($ps), 'Domain::PublicSuffix',                       , 'create-object' );
is( $ps->get_root_domain('google.com'), 'google.com'        , 'root-to-root-com' );
is( $ps->tld(), 'com',                                      , 'domain-error' );

$ps = Domain::PublicSuffix->new({ 
    'data_file' => 'effective_tld_names.dat'
});

is( ref($ps), 'Domain::PublicSuffix',                       , 'create-external-object' );
is( $ps->get_root_domain('www.domain.me'), 'domain.me'      , 'external-me' );
is( $ps->tld(), 'me',                                       , 'external-me-tld' );

done_testing();

1;