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 exit 0; 14 } 15} 16 17use Test::More tests => 11; 18 19BEGIN { use_ok('PerlIO::via::QuotedPrint') } 20 21my $file = 'test.qp'; 22 23my $decoded = <<EOD; 24This is a t�st for quoted-printable text that has h�rdly any spe�ial characters 25in it. 26EOD 27 28my $encoded = <<EOD; 29This is a t=E9st for quoted-printable text that has h=E0rdly any spe=E7ial = 30characters 31in it. 32EOD 33 34# Create the encoded test-file 35 36ok( 37 open( my $out,'>:via(PerlIO::via::QuotedPrint)', $file ), 38 "opening '$file' for writing" 39); 40 41ok( (print $out $decoded), 'print to file' ); 42ok( close( $out ), 'closing encoding handle' ); 43 44# Check encoding without layers 45 46{ 47local $/ = undef; 48ok( open( my $test, '<', $file ), 'opening without layer' ); 49is( $encoded,readline( $test ), 'check encoded content' ); 50ok( close( $test ), 'close test handle' ); 51} 52 53# Check decoding _with_ layers 54 55ok( 56 open( my $in,'<:via(QuotedPrint)', $file ), 57 "opening '$file' for reading" 58); 59is( $decoded,join( '',<$in> ), 'check decoding' ); 60ok( close( $in ), 'close decoding handle' ); 61 62# Remove whatever we created now 63 64ok( unlink( $file ), "remove test file '$file'" ); 651 while unlink $file; # multiversioned filesystems 66