diff options
author | Lorry Tar Creator <lorry-tar-importer@lorry> | 2015-07-31 18:59:09 +0000 |
---|---|---|
committer | Lorry Tar Creator <lorry-tar-importer@lorry> | 2015-07-31 18:59:09 +0000 |
commit | 42c8b23669eac442a303190dad44d78cea63cf59 (patch) | |
tree | 1cc49a1a1813bd802988e88058f353a4e0a23514 /t/19_bug_101240.t | |
download | Archive-Zip-tarball-42c8b23669eac442a303190dad44d78cea63cf59.tar.gz |
Archive-Zip-1.49HEADArchive-Zip-1.49master
Diffstat (limited to 't/19_bug_101240.t')
-rwxr-xr-x | t/19_bug_101240.t | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/t/19_bug_101240.t b/t/19_bug_101240.t new file mode 100755 index 0000000..a980f43 --- /dev/null +++ b/t/19_bug_101240.t @@ -0,0 +1,53 @@ +#!/usr/bin/perl + +use strict; + +BEGIN { + $| = 1; + $^W = 1; +} + +use Test::More tests => 4; +use File::Spec; +use File::Path; +use Archive::Zip qw(:CONSTANTS); + +use t::common; + +#101240: Possible issue with zero length files on Win32 when UNICODE is enabled + + +my $test_dir = File::Spec->catdir(TESTDIR, "empty"); +my $input_file = File::Spec->catfile($test_dir, "empty.zip"); +mkpath($test_dir); + +{ + # Create a zip file that contains a member where compressed size is 0 + + my $zip = Archive::Zip->new(); + my $string_member = $zip->addString( '', 'fred' ); + $string_member->desiredCompressionMethod( COMPRESSION_STORED ); + $zip->writeToFileNamed($input_file) ; +} + +for my $unicode (0, 1) +{ + local $Archive::Zip::UNICODE = $unicode; + + my $zip = Archive::Zip->new(); + + $zip->read($input_file); + + my $test_file = File::Spec->catfile($test_dir, "test_file$unicode"); + + $zip->memberNamed("fred")->extractToFileNamed($test_file); + + # TEST + ok -e $test_file, "[UNICODE=$unicode] output file exists"; + is -s $test_file, 0, "[UNICODE=$unicode] output file is empty"; + + # Clean up. + #unlink $test_file; +} + +#rmtree($test_dir); |