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