This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
regexec.c: White space only; no code changes
[perl5.git] / cpan / PerlIO-via-QuotedPrint / t / QuotedPrint.t
1 BEGIN {                         # 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
11 use strict;
12 use warnings;
13 use Test::More tests => 11;
14
15 BEGIN { use_ok('PerlIO::via::QuotedPrint') }
16
17 my $file = 'test.qp';
18
19 my $decoded = <<EOD;
20 This is a tést for quoted-printable text that has hàrdly any speçial characters
21 in it.
22 EOD
23
24 my $encoded = <<EOD;
25 This is a t=E9st for quoted-printable text that has h=E0rdly any spe=E7ial =
26 characters
27 in it.
28 EOD
29
30 # Create the encoded test-file
31
32 ok(
33  open( my $out,'>:via(PerlIO::via::QuotedPrint)', $file ),
34  "opening '$file' for writing"
35 );
36
37 ok( (print $out $decoded),              'print to file' );
38 ok( close( $out ),                      'closing encoding handle' );
39
40 # Check encoding without layers
41
42 {
43 local $/ = undef;
44 ok( open( my $test,$file ),             'opening without layer' );
45 is( $encoded,readline( $test ),         'check encoded content' );
46 ok( close( $test ),                     'close test handle' );
47 }
48
49 # Check decoding _with_ layers
50
51 ok(
52  open( my $in,'<:via(QuotedPrint)', $file ),
53  "opening '$file' for reading"
54 );
55 is( $decoded,join( '',<$in> ),          'check decoding' );
56 ok( close( $in ),                       'close decoding handle' );
57
58 # Remove whatever we created now
59
60 ok( unlink( $file ),                    "remove test file '$file'" );
61 1 while unlink $file; # multiversioned filesystems