summaryrefslogtreecommitdiff
path: root/lib/PerlIO/via/t/QuotedPrint.t
diff options
context:
space:
mode:
authorJarkko Hietaniemi <jhi@iki.fi>2002-07-09 21:31:44 +0000
committerJarkko Hietaniemi <jhi@iki.fi>2002-07-09 21:31:44 +0000
commite934609f7db1163b003ba7314f8d52ebfc1e2f12 (patch)
tree74e172d331579be10555103b1caf5cdfd80b687d /lib/PerlIO/via/t/QuotedPrint.t
parentcaf25f3be4a66b8fbb51db2cfdfa658f6b9704e7 (diff)
downloadperl-e934609f7db1163b003ba7314f8d52ebfc1e2f12.tar.gz
Change PerlIO::Scalar and Via to scalar and via.
p4raw-id: //depot/perl@17454
Diffstat (limited to 'lib/PerlIO/via/t/QuotedPrint.t')
-rw-r--r--lib/PerlIO/via/t/QuotedPrint.t55
1 files changed, 55 insertions, 0 deletions
diff --git a/lib/PerlIO/via/t/QuotedPrint.t b/lib/PerlIO/via/t/QuotedPrint.t
new file mode 100644
index 0000000000..c1367c0412
--- /dev/null
+++ b/lib/PerlIO/via/t/QuotedPrint.t
@@ -0,0 +1,55 @@
+my $file = 'test.qp';
+
+BEGIN {
+ if ($ENV{PERL_CORE}) {
+ chdir 't' if -d 't';
+ @INC = '../lib';
+ }
+}
+
+use Test::More tests => 11;
+
+BEGIN { use_ok('PerlIO::via::QuotedPrint') }
+
+my $decoded = <<EOD;
+This is a tést for quoted-printable text that has hàrdly any speçial 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(PerlIO::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'" );