1use 5.008001;
2
3use strict;
4use warnings;
5
6BEGIN {                         # Magic Perl CORE pragma
7    unless (find PerlIO::Layer 'perlio') {
8        print "1..0 # Skip: PerlIO not used\n";
9        exit 0;
10    }
11    if (ord("A") == 193) {
12        print "1..0 # Skip: EBCDIC\n";
13    }
14}
15
16use Test::More tests => 11;
17
18BEGIN { use_ok('PerlIO::via::QuotedPrint') }
19
20my $file = 'test.qp';
21
22my $decoded = <<EOD;
23This is a t�st for quoted-printable text that has h�rdly any spe�ial characters
24in it.
25EOD
26
27my $encoded = <<EOD;
28This is a t=E9st for quoted-printable text that has h=E0rdly any spe=E7ial =
29characters
30in it.
31EOD
32
33# Create the encoded test-file
34
35ok(
36 open( my $out,'>:via(PerlIO::via::QuotedPrint)', $file ),
37 "opening '$file' for writing"
38);
39
40ok( (print $out $decoded),              'print to file' );
41ok( close( $out ),                      'closing encoding handle' );
42
43# Check encoding without layers
44
45{
46local $/ = undef;
47ok( open( my $test, '<', $file ),       'opening without layer' );
48is( $encoded,readline( $test ),         'check encoded content' );
49ok( close( $test ),                     'close test handle' );
50}
51
52# Check decoding _with_ layers
53
54ok(
55 open( my $in,'<:via(QuotedPrint)', $file ),
56 "opening '$file' for reading"
57);
58is( $decoded,join( '',<$in> ),          'check decoding' );
59ok( close( $in ),                       'close decoding handle' );
60
61# Remove whatever we created now
62
63ok( unlink( $file ),                    "remove test file '$file'" );
641 while unlink $file; # multiversioned filesystems
65