user/dev discussion of public-inbox itself
 help / color / mirror / code / Atom feed
blob e35e4f8b0a1eb2d45032fb4ed37cef48802aac4b 1246 bytes (raw)
name: t/address.t 	 # note: path name is non-authoritative(*)

 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
 
# Copyright (C) 2016-2018 all contributors <meta@public-inbox.org>
# License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
use strict;
use warnings;
use Test::More;
use_ok 'PublicInbox::Address';

is_deeply([qw(e@example.com e@example.org)],
	[PublicInbox::Address::emails('User <e@example.com>, e@example.org')],
	'address extraction works as expected');

is_deeply([PublicInbox::Address::emails('"ex@example.com" <ex@example.com>')],
	[qw(ex@example.com)]);

my @names = PublicInbox::Address::names(
	'User <e@e>, e@e, "John A. Doe" <j@d>, <x@x>');
is_deeply(['User', 'e', 'John A. Doe', 'x'], \@names,
	'name extraction works as expected');

@names = PublicInbox::Address::names('"user@example.com" <user@example.com>');
is_deeply(['user'], \@names, 'address-as-name extraction works as expected');


{
	my $backwards = 'u@example.com (John Q. Public)';
	@names = PublicInbox::Address::names($backwards);
	is_deeply(\@names, ['u'], 'backwards name OK');
	my @emails = PublicInbox::Address::emails($backwards);
	is_deeply(\@emails, ['u@example.com'], 'backwards emails OK');
}


@names = PublicInbox::Address::names('"Quote Unneeded" <user@example.com>');
is_deeply(['Quote Unneeded'], \@names, 'extra quotes dropped');

done_testing;

debug log:

solving e35e4f8 ...
found e35e4f8 in https://80x24.org/public-inbox.git

(*) Git path names are given by the tree(s) the blob belongs to.
    Blobs themselves have no identifier aside from the hash of its contents.^

Code repositories for project(s) associated with this public inbox

	https://80x24.org/public-inbox.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).