1 # Copyright (C) 2013-2020 all contributors <meta@public-inbox.org>
2 # License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
5 use PublicInbox::TestCommon;
6 require_mods('Plack::Util');
7 use_ok 'PublicInbox::View';
9 # this only tests View.pm internals which are subject to change,
10 # see t/plack.t for tests against the PSGI interface.
12 my $cols = PublicInbox::View::COLS();
14 until (length(join(', ', @addr)) > ($cols * 2)) {
15 push @addr, '"l, f" <a@a>';
16 my $n = int(rand(20)) + 1;
17 push @addr, ('x'x$n).'@x';
19 my $orig = join(', ', @addr);
20 my $res = PublicInbox::View::fold_addresses($orig.'');
21 isnt($res, $orig, 'folded result');
22 unlike($res, qr/l,\n\tf/s, '"last, first" no broken');
23 my @nospc = ($res, $orig);
25 is($nospc[0], $nospc[1], 'no addresses lost in translation');
26 my $tws = PublicInbox::View::fold_addresses($orig.' ');
27 # (Email::Simple drops leading whitespace, but not trailing)
29 is($tws, $res, 'not thrown off by trailing whitespace');