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