1 # Copyright (C) 2016-2019 all contributors <meta@public-inbox.org>
2 # License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
6 use_ok 'PublicInbox::Address';
8 is_deeply([qw(e@example.com e@example.org)],
9 [PublicInbox::Address::emails('User <e@example.com>, e@example.org')],
10 'address extraction works as expected');
12 is_deeply(['user@example.com'],
13 [PublicInbox::Address::emails('<user@example.com (Comment)>')],
14 'comment after domain accepted before >');
16 my @names = PublicInbox::Address::names(
17 'User <e@e>, e@e, "John A. Doe" <j@d>, <x@x>');
18 is_deeply(['User', 'e', 'John A. Doe', 'x'], \@names,
19 'name extraction works as expected');
21 @names = PublicInbox::Address::names('"user@example.com" <user@example.com>');
22 is_deeply(['user'], \@names, 'address-as-name extraction works as expected');
26 my $backwards = 'u@example.com (John Q. Public)';
27 @names = PublicInbox::Address::names($backwards);
28 is_deeply(\@names, ['u'], 'backwards name OK');
29 my @emails = PublicInbox::Address::emails($backwards);
30 is_deeply(\@emails, ['u@example.com'], 'backwards emails OK');
34 @names = PublicInbox::Address::names('"Quote Unneeded" <user@example.com>');
35 is_deeply(['Quote Unneeded'], \@names, 'extra quotes dropped');