File: 02-none.t

package info (click to toggle)
libmail-authenticationresults-perl 2.20250709-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 376 kB
  • sloc: perl: 2,860; makefile: 2
file content (35 lines) | stat: -rw-r--r-- 1,622 bytes parent folder | download | duplicates (4)
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
#!perl
use 5.008;
use strict;
use warnings FATAL => 'all';
use lib 't';
use Test::More;
use Test::Exception;

use lib 'lib';
use Mail::AuthenticationResults::Parser;

my $Parsed;

lives_ok( sub{ $Parsed = Mail::AuthenticationResults::Parser->new()->parse( 'example.com;none' ) }, 'Simple none parses' );
is( $Parsed->as_string, "example.com; none", 'as string is as expected' );
is( scalar @{ $Parsed->children() }, 0, 'no children' );

lives_ok( sub{ $Parsed = Mail::AuthenticationResults::Parser->new()->parse( 'example.com;' ) }, 'Missing none parses' );
is( $Parsed->as_string, "example.com; none", 'as string is as expected' );
is( scalar @{ $Parsed->children() }, 0, 'no children' );

lives_ok( sub{ $Parsed = Mail::AuthenticationResults::Parser->new()->parse( 'example.com; (Nothing here) none' ) }, 'Commented none parses' );
is( $Parsed->as_string, "example.com; (Nothing here) none", 'as string is as expected' );
is( scalar @{ $Parsed->children() }, 1, '1 child' );

# The following is against RFC, but we parse it anyway.
lives_ok( sub{ $Parsed = Mail::AuthenticationResults::Parser->new()->parse( 'example.com; none (Nothing here)' ) }, 'Commented none wrong way around parses' );
is( $Parsed->as_string, "example.com; (Nothing here) none", 'as string is as expected' );
is( scalar @{ $Parsed->children() }, 1, '1 child' );

dies_ok( sub{ $Parsed = Mail::AuthenticationResults::Parser->new()->parse( 'example.com; none dkim=pass' ) }, 'none with subentry dies' );
dies_ok( sub{ $Parsed = Mail::AuthenticationResults::Parser->new()->parse( 'example.com; none none' ) }, 'double none dies' );

done_testing();