]> Sergey Matveev's repositories - public-inbox.git/blob - t/content_hash.t
update copyrights for 2021
[public-inbox.git] / t / content_hash.t
1 # Copyright (C) 2018-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 warnings;
5 use Test::More;
6 use PublicInbox::ContentHash qw(content_hash);
7 use PublicInbox::Eml;
8
9 my $mime = PublicInbox::Eml->new(<<'EOF');
10 From: a@example.com
11 To: b@example.com
12 Subject: this is a subject
13 Message-ID: <a@example.com>
14 Date: Fri, 02 Oct 1993 00:00:00 +0000
15
16 hello world
17 EOF
18
19 my $orig = content_hash($mime);
20 my $reload = content_hash(PublicInbox::Eml->new($mime->as_string));
21 is($orig, $reload, 'content_hash matches after serialization');
22
23 foreach my $h (qw(From To Cc)) {
24         my $n = q("Quoted N'Ame" <foo@EXAMPLE.com>);
25         $mime->header_set($h, "$n");
26         my $q = content_hash($mime);
27         is($mime->header($h), $n, "content_hash does not mutate $h:");
28         $mime->header_set($h, 'Quoted N\'Ame <foo@example.com>');
29         my $nq = content_hash($mime);
30         is($nq, $q, "quotes ignored in $h:");
31 }
32
33 done_testing();