1BEGIN { # Magic Perl CORE pragma 2 if ($ENV{PERL_CORE}) { 3 chdir 't' if -d 't'; 4 @INC = '../lib'; 5 } 6 unless (find PerlIO::Layer 'perlio') { 7 print "1..0 # Skip: PerlIO not used\n"; 8 exit 0; 9 } 10 if (ord("A") == 193) { 11 print "1..0 # Skip: EBCDIC\n"; 12 } 13} 14 15use strict; 16use warnings; 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'" ); 65