File: 05-as_string-wrap.t

package info (click to toggle)
libmail-authenticationresults-perl 2.20210112-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 356 kB
  • sloc: perl: 2,679; makefile: 2
file content (86 lines) | stat: -rw-r--r-- 2,651 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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#!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 $InputARHeader = 'test.example.com; foo=bar string1=string string2=string string3=string string4=string string5=string string6=string';

subtest 'No folding' => sub{
    my $Parser = Mail::AuthenticationResults::Parser->new( $InputARHeader );
    my $Parsed = $Parser->parsed();
    $Parsed->set_indent_style( 'none' );
    is( $Parsed->as_string(), $InputARHeader, 'stringifies ok' );
};

subtest 'Set folding' => sub{
    my $Parser = Mail::AuthenticationResults::Parser->new( $InputARHeader );
    my $Parsed = $Parser->parsed();
    is( $Parsed->fold_at(), undef, 'Fold at starts undefined' );
    lives_ok( sub{ $Parsed->set_fold_at( 5 ); }, 'set_fold_at lives' );
    is( $Parsed->fold_at(), 5, 'Fold at has been set' );
    is( $Parsed->force_fold_at(), undef, 'Force fold at starts undefined' );
    lives_ok( sub{ $Parsed->set_force_fold_at( 800 ); }, 'set_force_fold_at lives' );
    is( $Parsed->force_fold_at(), 800, 'Force fold at has been set' );
};

subtest 'Extra Short folding' => sub{
    my $Parser = Mail::AuthenticationResults::Parser->new( $InputARHeader );
    my $Parsed = $Parser->parsed();
    $Parsed->set_fold_at( 18 );
    $Parsed->set_indent_style( 'entry' );
    my $OutputARHeader = 'test.example.com;
    foo=bar
      string1=
      string
      string2=
      string
      string3=
      string
      string4=
      string
      string5=
      string
      string6=
      string';
    is( $Parsed->as_string(), $OutputARHeader, 'stringifies ok' );
};

subtest 'Short folding' => sub{
    my $Parser = Mail::AuthenticationResults::Parser->new( $InputARHeader );
    my $Parsed = $Parser->parsed();
    $Parsed->set_fold_at( 21 );
    $Parsed->set_indent_style( 'entry' );
    my $OutputARHeader = 'test.example.com;
    foo=bar
      string1=string
      string2=string
      string3=string
      string4=string
      string5=string
      string6=string';
    is( $Parsed->as_string(), $OutputARHeader, 'stringifies ok' );
};

subtest 'Longer folding' => sub{
    my $Parser = Mail::AuthenticationResults::Parser->new( $InputARHeader );
    my $Parsed = $Parser->parsed();
    $Parsed->set_fold_at( 40 );
    $Parsed->set_indent_style( 'entry' );
    my $OutputARHeader = 'test.example.com;
    foo=bar string1=string
      string2=string string3=string
      string4=string string5=string
      string6=string';
    is( $Parsed->as_string(), $OutputARHeader, 'stringifies ok' );
};

# Force fold at is not currently implemented

done_testing();