summaryrefslogtreecommitdiff
path: root/cpan/IO-Compress/t
diff options
context:
space:
mode:
authorChris 'BinGOs' Williams <chris@bingosnet.co.uk>2012-12-15 19:50:36 +0000
committerChris 'BinGOs' Williams <chris@bingosnet.co.uk>2012-12-15 19:50:36 +0000
commit496575ce841293eaf818395fc1f56e7fb74a18cc (patch)
treee7b46477eae9fe48b76792398fdcecebd7b5f01d /cpan/IO-Compress/t
parentcd346b2859236d69de687d1baa46c23e19af2202 (diff)
downloadperl-496575ce841293eaf818395fc1f56e7fb74a18cc.tar.gz
Update IO-Compress to CPAN version 2.059
[DELTA] 2.059 10 December 2012 * IO::Compress::Base Added "Encode" option.
Diffstat (limited to 'cpan/IO-Compress/t')
-rw-r--r--cpan/IO-Compress/t/000prereq.t2
-rw-r--r--cpan/IO-Compress/t/01misc.t35
-rw-r--r--cpan/IO-Compress/t/compress/encode.pl89
-rw-r--r--cpan/IO-Compress/t/cz-14gzopen.t3
4 files changed, 120 insertions, 9 deletions
diff --git a/cpan/IO-Compress/t/000prereq.t b/cpan/IO-Compress/t/000prereq.t
index 3903e37454..98ca688693 100644
--- a/cpan/IO-Compress/t/000prereq.t
+++ b/cpan/IO-Compress/t/000prereq.t
@@ -25,7 +25,7 @@ BEGIN
if eval { require Test::NoWarnings ; import Test::NoWarnings; 1 };
- my $VERSION = '2.058';
+ my $VERSION = '2.059';
my @NAMES = qw(
Compress::Raw::Bzip2
Compress::Raw::Zlib
diff --git a/cpan/IO-Compress/t/01misc.t b/cpan/IO-Compress/t/01misc.t
index 352fbcdf99..150fb69bd6 100644
--- a/cpan/IO-Compress/t/01misc.t
+++ b/cpan/IO-Compress/t/01misc.t
@@ -19,7 +19,7 @@ BEGIN {
$extra = 1
if eval { require Test::NoWarnings ; import Test::NoWarnings; 1 };
- plan tests => 150 + $extra ;
+ plan tests => 163 + $extra ;
use_ok('Scalar::Util');
use_ok('IO::Compress::Base::Common');
@@ -153,6 +153,39 @@ sub My::testParseParameters()
is $got1->getValue('fred'), 0;
}
+ {
+ # setValue/getValue
+ my $value = 0;
+ my $got1 ;
+ eval { $got1 = ParseParameters(1, {'fred' => [Parse_any, 1]}, fred => $value) } ;
+
+ ok ! $@;
+ ok $got1->parsed('fred'), "parsed ok" ;
+ is $got1->getValue('fred'), 0;
+ $got1->setValue('fred' => undef);
+ is $got1->getValue('fred'), undef;
+ }
+
+ {
+ # twice
+ my $value = 0;
+
+ my $got = IO::Compress::Base::Parameters::new();
+
+
+ ok $got->parse({'fred' => [Parse_any, 1]}, fred => $value) ;
+
+ ok $got->parsed('fred'), "parsed ok" ;
+ is $got->getValue('fred'), 0;
+
+ ok $got->parse({'fred' => [Parse_any, 1]}, fred => undef) ;
+ ok $got->parsed('fred'), "parsed ok" ;
+ is $got->getValue('fred'), undef;
+
+ ok $got->parse({'fred' => [Parse_any, 1]}, fred => 7) ;
+ ok $got->parsed('fred'), "parsed ok" ;
+ is $got->getValue('fred'), 7;
+ }
}
diff --git a/cpan/IO-Compress/t/compress/encode.pl b/cpan/IO-Compress/t/compress/encode.pl
index 142bd08e59..875f0ceab7 100644
--- a/cpan/IO-Compress/t/compress/encode.pl
+++ b/cpan/IO-Compress/t/compress/encode.pl
@@ -1,7 +1,7 @@
use strict;
use warnings;
-use bytes;
+#use bytes;
use Test::More ;
use CompTestUtils;
@@ -23,7 +23,7 @@ BEGIN
$extra = 1
if $st ;
- plan(tests => 7 + $extra) ;
+ plan(tests => 29 + $extra) ;
}
sub run
@@ -34,7 +34,7 @@ sub run
my $UnError = getErrorRef($UncompressClass);
- my $string = "\x{df}\x{100}";
+ my $string = "\x{df}\x{100}\x80";
my $encString = Encode::encode_utf8($string);
my $buffer = $encString;
@@ -92,10 +92,13 @@ sub run
my $ucs = new $UncompressClass($input, Append => 1);
my $got;
1 while $ucs->read($got) > 0 ;
+
+ is $got, $encString, " Expected output";
+
my $decode = Encode::decode_utf8($got);
- is $string, $decode, " Expected output";
+ is $decode, $string, " Expected output";
}
@@ -110,9 +113,81 @@ sub run
eval { $cs->syswrite($a) };
like($@, qr/Wide character in ${CompressClass}::write/,
" wide characters in ${CompressClass}::write");
- eval { syswrite($cs, $a) };
- like($@, qr/Wide character in ${CompressClass}::write/,
- " wide characters in ${CompressClass}::write");
+
+ }
+
+ {
+ title "Unknown encoding";
+ my $output;
+ eval { my $cs = new $CompressClass(\$output, Encode => 'fred'); } ;
+ like($@, qr/${CompressClass}: Encoding 'fred' is not available/,
+ " Encoding 'fred' is not available");
+ }
+
+ {
+ title "Encode option";
+
+ for my $to ( qw(filehandle filename buffer))
+ {
+ title "Encode: To $to, Encode option";
+
+ my $lex2 = new LexFile my $name2 ;
+ my $output;
+ my $buffer;
+
+ if ($to eq 'buffer')
+ {
+ $output = \$buffer
+ }
+ elsif ($to eq 'filename')
+ {
+ $output = $name2 ;
+ }
+ elsif ($to eq 'filehandle')
+ {
+ $output = new IO::File ">$name2" ;
+ }
+
+ my $out ;
+ my $cs = new $CompressClass($output, AutoClose =>1, Encode => 'utf8');
+ ok $cs->print($string);
+ ok $cs->close();
+
+ my $input;
+ if ($to eq 'buffer')
+ {
+ $input = \$buffer
+ }
+ elsif ($to eq 'filename')
+ {
+ $input = $name2 ;
+ }
+ else
+ {
+ $input = new IO::File "<$name2" ;
+ }
+
+ {
+ my $ucs = new $UncompressClass($input, AutoClose =>1, Append => 1);
+ my $got;
+ 1 while $ucs->read($got) > 0 ;
+ ok length($got) > 0;
+ is $got, $encString, " Expected output";
+
+ my $decode = Encode::decode_utf8($got);
+
+ is $decode, $string, " Expected output";
+ }
+
+
+# {
+# my $ucs = new $UncompressClass($input, Append => 1, Decode => 'utf8');
+# my $got;
+# 1 while $ucs->read($got) > 0 ;
+# ok length($got) > 0;
+# is $got, $string, " Expected output";
+# }
+ }
}
}
diff --git a/cpan/IO-Compress/t/cz-14gzopen.t b/cpan/IO-Compress/t/cz-14gzopen.t
index d5f0ea0c04..01d2d65a2b 100644
--- a/cpan/IO-Compress/t/cz-14gzopen.t
+++ b/cpan/IO-Compress/t/cz-14gzopen.t
@@ -489,6 +489,9 @@ foreach my $stdio ( ['-', '-'], [*STDIN, *STDOUT])
SKIP:
{
+ skip "Cannot create non-writable file", 3
+ if $^O eq 'cygwin';
+
my $lex = new LexFile my $name ;
writeFile($name, "abc");
chmod 0444, $name