doc: Move Perl version baseline as the first perl coding style subsection
[dpkg.git] / scripts / t / Dpkg_OpenPGP_KeyHandle.t
blob23a8c9b8fb9b7e5b150eadfb44ae27edd5a3e26f
1 #!/usr/bin/perl
3 # This program is free software; you can redistribute it and/or modify
4 # it under the terms of the GNU General Public License as published by
5 # the Free Software Foundation; either version 2 of the License, or
6 # (at your option) any later version.
8 # This program is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # GNU General Public License for more details.
13 # You should have received a copy of the GNU General Public License
14 # along with this program. If not, see <https://www.gnu.org/licenses/>.
16 use strict;
17 use warnings;
19 use Test::More tests => 21;
21 BEGIN {
22 use_ok('Dpkg::OpenPGP::KeyHandle');
25 my @ref_keys = (
27 type => 'auto',
28 handle => '0x12345678',
29 exp_type => 'keyid',
30 exp_handle => '12345678',
31 }, {
32 type => 'auto',
33 handle => '0x1234567890abcdef',
34 exp_type => 'keyid',
35 exp_handle => '1234567890abcdef',
36 }, {
37 type => 'auto',
38 handle => '0x1234567890abcdef1234567890abcdef',
39 exp_type => 'keyid',
40 exp_handle => '1234567890abcdef1234567890abcdef',
41 }, {
42 type => 'auto',
43 handle => 'Alice Auster',
44 exp_type => 'userid',
45 exp_handle => 'Alice Auster',
46 }, {
47 type => 'auto',
48 handle => 'Alice Auster <alice@example.org>',
49 exp_type => 'userid',
50 exp_handle => 'Alice Auster <alice@example.org>',
51 }, {
52 type => 'keyid',
53 handle => '0x12345678',
54 exp_type => 'keyid',
55 exp_handle => '12345678',
56 }, {
57 type => 'keyid',
58 handle => '0x1234567890abcdef',
59 exp_type => 'keyid',
60 exp_handle => '1234567890abcdef',
61 }, {
62 type => 'keyid',
63 handle => '0x1234567890abcdef1234567890abcdef',
64 exp_type => 'keyid',
65 exp_handle => '1234567890abcdef1234567890abcdef',
66 }, {
67 type => 'userid',
68 handle => 'Alice Auster',
69 exp_type => 'userid',
70 exp_handle => 'Alice Auster',
71 }, {
72 type => 'userid',
73 handle => 'Alice Auster <alice@example.org>',
74 exp_type => 'userid',
75 exp_handle => 'Alice Auster <alice@example.org>',
79 foreach my $ref_key (@ref_keys) {
80 my $key = Dpkg::OpenPGP::KeyHandle->new(
81 type => $ref_key->{type},
82 handle => $ref_key->{handle},
84 is($key->type, $ref_key->{exp_type},
85 'key type ' . $key->type . " sanitized as $ref_key->{exp_type}");
86 is($key->handle, $ref_key->{exp_handle},
87 'key handle ' . $key->handle . " sanitized as $ref_key->{exp_handle}");
90 # TODO: Add actual test cases.