1#!perl
2use 5.008;
3use strict;
4use warnings FATAL => 'all';
5use lib 't';
6use Test::More;
7use Test::Exception;
8
9use lib 'lib';
10use Mail::AuthenticationResults::Parser;
11
12my $Input = [
13  'iprev=fail policy.iprev=123.123.123.123 (NOT FOUND)',
14  'x-ptr=fail x-ptr-helo=bad.name.google.com x-ptr-lookup=',
15];
16
17my $InputARHeader = join( ";\n", 'test.example.com', @$Input );
18
19my $Parser = Mail::AuthenticationResults::Parser->new( $InputARHeader );
20my $Parsed = $Parser->parsed();
21
22my $LR = "test.example.com;\n    iprev=fail policy.iprev=123.123.123.123 (NOT FOUND);\n    x-ptr=fail x-ptr-helo=bad.name.google.com x-ptr-lookup=\"\"";
23my $CRLF = "test.example.com;\r\n    iprev=fail policy.iprev=123.123.123.123 (NOT FOUND);\r\n    x-ptr=fail x-ptr-helo=bad.name.google.com x-ptr-lookup=\"\"";
24
25$Parsed->set_indent_style( 'entry' );
26
27is( $Parsed->as_string(), $LR, 'Default is LR' );
28$Parsed->set_eol( "\r\n" );
29is( $Parsed->as_string(), $CRLF, 'Set CRLR' );
30$Parsed->set_eol( "\n" );
31is( $Parsed->as_string(), $LR, 'Set LR' );
32
33dies_ok( sub{ $Parsed->set_eol( "**" ); }, 'Invalid eol dies' );
34
35done_testing();
36
37