Plan 9 from Bell Labs’s /usr/web/sources/contrib/gabidiaz/root/sys/src/cmd/perl/lib/PerlIO/via/t/QuotedPrint.t

Copyright © 2021 Plan 9 Foundation.
Distributed under the MIT License.
Download the Plan 9 distribution.


my $file = 'test.qp';

BEGIN {
    if ($ENV{PERL_CORE}) {	
	chdir 't' if -d 't';
	@INC = '../lib';
    }
    unless (find PerlIO::Layer 'perlio') {
        print "1..0 # Skip: PerlIO not used\n";
	exit 0;
    }
    if (ord("A") == 193) {
	print "1..0 # Skip: EBCDIC\n";
    }
}

use Test::More tests => 11;

BEGIN { use_ok('PerlIO::via::QuotedPrint') }

my $decoded = <<EOD;
This is a t� for quoted-printable text that has h�ly any spe�l characters
in it.
EOD

my $encoded = <<EOD;
This is a t=E9st for quoted-printable text that has h=E0rdly any spe=E7ial =
characters
in it.
EOD

# Create the encoded test-file

ok(
 open( my $out,'>:via(PerlIO::via::QuotedPrint)', $file ),
 "opening '$file' for writing"
);

ok( (print $out $decoded),		'print to file' );
ok( close( $out ),			'closing encoding handle' );

# Check encoding without layers

{
local $/ = undef;
ok( open( my $test,$file ),		'opening without layer' );
is( $encoded,readline( $test ),		'check encoded content' );
ok( close( $test ),			'close test handle' );
}

# Check decoding _with_ layers

ok(
 open( my $in,'<:via(QuotedPrint)', $file ),
 "opening '$file' for reading"
);
is( $decoded,join( '',<$in> ),		'check decoding' );
ok( close( $in ),			'close decoding handle' );

# Remove whatever we created now

ok( unlink( $file ),			"remove test file '$file'" );

Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to [email protected].