forked from perl-Crypt-OpenPGP/Convert-PEM
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path04-explode.t
38 lines (29 loc) · 1017 Bytes
/
04-explode.t
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
37
38
use strict;
use Test::More tests => 4;
use Convert::PEM;
my $pem = Convert::PEM->new(
'Name' => 'TEST OBJECT',
'ASN' => q(
TestObject SEQUENCE {
int INTEGER
}
)
);
isa_ok( $pem, 'Convert::PEM' );
my %pemhash = (
'Object' => 'TEST OBJECT',
'Content' => 'Simple test content that is long enough to wrap in base64.',
'Headers' =>
[ [ 'A' => 'Alpha' ], [ 'B' => 'Bravo' ], [ 'C' => 'Charlie' ] ],
);
my $pemData = $pem->implode( %pemhash );
my $pemUnix = my $pemDos = my $pemOldMac = $pemData;
$pemUnix =~ s/\r\n|\n|\r/\n/g;
$pemDos =~ s/\r\n|\n|\r/\r\n/g;
$pemOldMac =~ s/\r\n|\n|\r/\r/g;
my $explodeUnix = $pem->explode( $pemUnix );
is_deeply( $explodeUnix, \%pemhash, "explode with unix line break" );
my $explodeDos = $pem->explode( $pemDos );
is_deeply( $explodeDos, \%pemhash, "explode with dos line break" );
my $explodeOldMac = $pem->explode( $pemOldMac );
is_deeply( $explodeOldMac, \%pemhash, "explode with old mac line break" );