18 plan skip_all => "Encode is not available"
21 eval { require Encode; Encode->import(); };
23 plan skip_all => "Encode is not available"
26 # use Test::NoWarnings, if available
29 if eval { require Test::NoWarnings ; import Test::NoWarnings; 1 };
31 plan tests => 16 + $extra ;
33 use_ok('Compress::Zlib', 2);
39 # Check zlib_version and ZLIB_VERSION are the same.
40 is Compress::Zlib::zlib_version, ZLIB_VERSION,
41 "ZLIB_VERSION matches Compress::Zlib::zlib_version" ;
46 # length of this string is 2 characters
47 my $s = "\x{df}\x{100}";
49 my $cs = Compress::Zlib::memGzip($s);
51 # length stored at end of gzip file should be 4
52 my ($crc, $len) = unpack ("VV", substr($cs, -8, 8));
54 is $len, 4, "length is 4";
59 # length of this string is 2 characters
60 my $s = "\x{df}\x{100}";
62 my $cs = Compress::Zlib::memGzip(Encode::encode_utf8($s));
64 # length stored at end of gzip file should be 4
65 my ($crc, $len) = unpack ("VV", substr($cs, -8, 8));
67 is $len, 4, " length is 4";
71 title "compress/uncompress";
73 my $s = "\x{df}\x{100}";
76 #my $cs = compress($s);
77 my $ces = compress(Encode::encode_utf8($s_copy));
79 ok $ces, " compressed ok" ;
83 #my $un = uncompress($cs);
86 my $un = Encode::decode_utf8(uncompress($ces));
87 #my $un = uncompress($ces);
88 is $un, $s, " decode_utf8 ok";
90 #$un = Encode::decode_utf8(uncompress($cs));
98 my $name = "test.gz" ;
99 my $s = "\x{df}\x{100}";
100 my $byte_len = length( Encode::encode_utf8($s) );
103 ok my $fil = gzopen($name, "wb"), " gzopen for write ok" ;
105 is $fil->gzwrite(Encode::encode_utf8($s)), $byte_len, " wrote $byte_len bytes" ;
107 ok ! $fil->gzclose, " gzclose ok" ;
109 ok $fil = gzopen($name, "rb"), " gzopen for read ok" ;
111 is $fil->gzread($uncomp), $byte_len, " read $byte_len bytes" ;
112 is length($uncomp), $byte_len, " uncompress is $byte_len bytes";
114 ok ! $fil->gzclose, "gzclose ok" ;
118 is $s, Encode::decode_utf8($uncomp), " decode_utf8 ok" ;
122 # Add tests that check that the module traps use of wide chars