12 plan skip_all => "Encode is not available"
15 eval { require Encode; Encode->import(); };
17 plan skip_all => "Encode is not available"
20 # use Test::NoWarnings, if available
23 if eval { require Test::NoWarnings ; import Test::NoWarnings; 1 };
25 plan tests => 16 + $extra ;
27 use_ok('Compress::Zlib', 2);
33 # Check zlib_version and ZLIB_VERSION are the same.
34 is Compress::Zlib::zlib_version, ZLIB_VERSION,
35 "ZLIB_VERSION matches Compress::Zlib::zlib_version" ;
40 # length of this string is 2 characters
41 my $s = "\x{df}\x{100}";
43 my $cs = Compress::Zlib::memGzip($s);
45 # length stored at end of gzip file should be 4
46 my ($crc, $len) = unpack ("VV", substr($cs, -8, 8));
48 is $len, 4, "length is 4";
53 # length of this string is 2 characters
54 my $s = "\x{df}\x{100}";
56 my $cs = Compress::Zlib::memGzip(Encode::encode_utf8($s));
58 # length stored at end of gzip file should be 4
59 my ($crc, $len) = unpack ("VV", substr($cs, -8, 8));
61 is $len, 4, " length is 4";
65 title "compress/uncompress";
67 my $s = "\x{df}\x{100}";
70 #my $cs = compress($s);
71 my $ces = compress(Encode::encode_utf8($s_copy));
73 ok $ces, " compressed ok" ;
77 #my $un = uncompress($cs);
80 my $un = Encode::decode_utf8(uncompress($ces));
81 #my $un = uncompress($ces);
82 is $un, $s, " decode_utf8 ok";
84 #$un = Encode::decode_utf8(uncompress($cs));
92 my $name = "test.gz" ;
93 my $s = "\x{df}\x{100}";
94 my $byte_len = length( Encode::encode_utf8($s) );
97 ok my $fil = gzopen($name, "wb"), " gzopen for write ok" ;
99 is $fil->gzwrite(Encode::encode_utf8($s)), $byte_len, " wrote $byte_len bytes" ;
101 ok ! $fil->gzclose, " gzclose ok" ;
103 ok $fil = gzopen($name, "rb"), " gzopen for read ok" ;
105 is $fil->gzread($uncomp), $byte_len, " read $byte_len bytes" ;
106 is length($uncomp), $byte_len, " uncompress is $byte_len bytes";
108 ok ! $fil->gzclose, "gzclose ok" ;
112 is $s, Encode::decode_utf8($uncomp), " decode_utf8 ok" ;
116 # Add tests that check that the module traps use of wide chars