]> Sergey Matveev's repositories - public-inbox.git/blob - t/view.t
No ext_urls
[public-inbox.git] / t / view.t
1 # Copyright (C) 2013-2021 all contributors <meta@public-inbox.org>
2 # License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
3 use strict;
4 use Test::More;
5 use PublicInbox::TestCommon;
6 require_mods('Plack::Util');
7 use_ok 'PublicInbox::View';
8
9 # this only tests View.pm internals which are subject to change,
10 # see t/plack.t for tests against the PSGI interface.
11
12 my $cols = PublicInbox::View::COLS();
13 my @addr;
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';
18 }
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);
24 s/\s+//g for @nospc;
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)
28 $tws =~ s/ \z//;
29 is($tws, $res, 'not thrown off by trailing whitespace');
30
31 done_testing();