File: 20.Report.URI.t

package info (click to toggle)
libmail-dmarc-perl 1.20240314-1
  • links: PTS
  • area: main
  • in suites: sid, trixie
  • size: 1,852 kB
  • sloc: perl: 4,944; xml: 13; makefile: 10; sh: 1
file content (49 lines) | stat: -rw-r--r-- 1,026 bytes parent folder | download | duplicates (2)
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
use strict;
use warnings;

use Data::Dumper;
use Test::More;

use lib 'lib';

my $mod = 'Mail::DMARC::Report::URI';
use_ok($mod);
my $uri = $mod->new;
isa_ok( $uri, $mod );

test_get_size_limit();
test_parse();

done_testing();
exit;

sub test_get_size_limit {
    my %tests = (
        '51m' => 53477376,
        '20k' => 20480,
        '5m'  => 5242880,
        '10m' => 10485760,
        '1g'  => 1073741824,
        '500' => 500,
    );

    foreach my $t ( keys %tests ) {
        cmp_ok( $uri->get_size_limit($t),
            '==', $tests{$t}, "get_size_limit, $tests{$t}" );
    }
}

sub test_parse {
    my @good = (
        'http://www.example.com/dmarc-feedback',
        'https://www.example.com/dmarc-feedback',
        'mailto:dmarc@example.com',
        'mailto:dmarc-feedback@example.com,mailto:tld-test@thirdparty.example.net!10m',
    );

    foreach (@good) {
        my $uris = $uri->parse($_);
        ok( $uris,         "parse, $_" );
        ok( scalar @$uris, "parse, count " . scalar @$uris );
    }
}