X-Git-Url: http://www.git.stargrave.org/?a=blobdiff_plain;f=t%2Fview.t;h=b829ecf883f8cca07cf28444e5ba4741578de57c;hb=4db4bfa2c9178b315d2ac09cff794a4476ba1f6e;hp=1f4ed9373a8857a385cea3a84b78c3226325c0dd;hpb=ef3ca9b80fcb464d851c2f8d87f3f02f4f70986d;p=public-inbox.git diff --git a/t/view.t b/t/view.t index 1f4ed937..b829ecf8 100644 --- a/t/view.t +++ b/t/view.t @@ -1,5 +1,5 @@ -# Copyright (C) 2013-2015 all contributors -# License: AGPLv3 or later (https://www.gnu.org/licenses/agpl-3.0.txt) +# Copyright (C) 2013-2018 all contributors +# License: AGPL-3.0+ use strict; use warnings; use Test::More; @@ -16,6 +16,7 @@ my $ctx = { base_url => sub { 'http://example.com/' }, cloneurl => sub {[]}, nntp_url => sub {[]}, + max_git_part => sub { undef }, description => sub { '' }), }; $ctx->{-inbox}->{-primary_address} = 'test@example.com'; @@ -169,4 +170,25 @@ EOF 'regular ID not compressed'); } +{ + my $cols = PublicInbox::View::COLS(); + my @addr; + until (length(join(', ', @addr)) > ($cols * 2)) { + push @addr, '"l, f" '; + my $n = int(rand(20)) + 1; + push @addr, ('x'x$n).'@x'; + } + my $orig = join(', ', @addr); + my $res = PublicInbox::View::fold_addresses($orig.''); + isnt($res, $orig, 'folded result'); + unlike($res, qr/l,\n\tf/s, '"last, first" no broken'); + my @nospc = ($res, $orig); + s/\s+//g for @nospc; + is($nospc[0], $nospc[1], 'no addresses lost in translation'); + my $tws = PublicInbox::View::fold_addresses($orig.' '); + # (Email::Simple drops leading whitespace, but not trailing) + $tws =~ s/ \z//; + is($tws, $res, 'not thrown off by trailing whitespace'); +} + done_testing();