use bytes;
use Test::More ;
-use ZlibTestUtils;
+use CompTestUtils;
use IO::Handle qw(SEEK_SET SEEK_CUR SEEK_END);
my $st = eval { require Test::NoWarnings ; import Test::NoWarnings; 1; };
$extra = 1
if $st ;
-
-
- plan(tests => 564 + $extra) ;
+ plan(tests => 597 + $extra) ;
}
-
-
-
sub myGZreadFile
{
my $filename = shift ;
sub run
{
-
my $CompressClass = identify();
$UncompressClass = getInverse($CompressClass);
my $Error = getErrorRef($CompressClass);
{
my $x ;
ok $x = new $CompressClass $name ;
+ is $x->autoflush(1), 0, "autoflush";
+ is $x->autoflush(1), 1, "autoflush";
+ ok $x->opened(), "opened";
ok $x->write($hello), "write" ;
ok $x->flush(), "flush";
ok $x->close, "close" ;
+ ok ! $x->opened(), "! opened";
}
{
my $uncomp;
ok my $x = new $UncompressClass $name, -Append => 1 ;
+ ok $x->opened(), "opened";
my $len ;
1 while ($len = $x->read($uncomp)) > 0 ;
ok $x->close ;
is $uncomp, $hello ;
+ ok !$x->opened(), "! opened";
}
}
my $lex = new LexFile my $name ;
+ #my $name = "/tmp/fred";
my $hello = <<EOM ;
hello world
{
my $lex = new LexFile my $name ;
+ #my $name = "/tmp/fred";
my $hello = <<EOM ;
hello world
ok 1, " wrote to stdout" ;
}
+ is myGZreadFile($name), $hello, " wrote OK";
+ #hexDump($name);
{
title "Input from stdin via filename '-'";
open(SAVEIN, "<&STDIN");
ok open(STDIN, "<$name"), " redirect STDIN";
my $dummy = fileno SAVEIN;
- $x = new $UncompressClass '-', Append => 1;
+ $x = new $UncompressClass '-', Append => 1, Transparent => 0
+ or diag $$UnError ;
ok $x, " created object" ;
is $x->fileno(), $stdinFileno, " fileno ok" ;
# and read back
#========================================
- my $name = "test.gz" ;
+ #my $name = "test.gz" ;
+ my $lex = new LexFile my $name ;
my $hello = <<EOM ;
hello world
my $x ;
ok $x = new $CompressClass(\$buffer) ;
+ ok ! defined $x->autoflush(1) ;
+ ok ! defined $x->autoflush(1) ;
ok ! defined $x->fileno() ;
is $x->write(''), 0, "Write empty string is ok";
is $x->write(undef), 0, "Write undef is ok";
my $x ;
ok $x = new $UncompressClass(\$buffer, Append => 1) ;
+ ok ! defined $x->autoflush(1) ;
+ ok ! defined $x->autoflush(1) ;
ok ! defined $x->fileno() ;
1 while $x->read($uncomp) > 0 ;
{
my $io = new $UncompressClass $name ;
+ is $., 0;
+ is $io->input_line_number, 0;
ok ! $io->eof;
is $io->tell(), 0 ;
#my @lines = <$io>;
is $lines[1], "of a paragraph\n" ;
is join('', @lines), $str ;
is $., 6;
+ is $io->input_line_number, 6;
is $io->tell(), length($str) ;
ok $io->eof;
{
local $/; # slurp mode
my $io = $UncompressClass->new($name);
+ is $., 0;
+ is $io->input_line_number, 0;
ok ! $io->eof;
my @lines = $io->getlines;
+ is $., 1;
+ is $io->input_line_number, 1;
ok $io->eof;
ok @lines == 1 && $lines[0] eq $str;
{
local $/ = ""; # paragraph mode
my $io = $UncompressClass->new($name);
+ is $., 0;
+ is $io->input_line_number, 0;
ok ! $io->eof;
my @lines = $io->getlines();
+ is $., 2;
+ is $io->input_line_number, 2;
ok $io->eof;
ok @lines == 2
or print "# Got " . scalar(@lines) . " lines, expected 2\n" ;
ok $err == 0 ;
ok $io->eof;
+ is $., 3;
+ is $io->input_line_number, 3;
ok @lines == 3
or print "# Got " . scalar(@lines) . " lines, expected 3\n" ;
ok join("-", @lines) eq
ok ! $io->eof;
ok $io->tell() == 0 ;
my @lines = $io->getlines();
- ok @lines == 6;
+ is @lines, 6;
ok $lines[1] eq "of a paragraph\n" ;
ok join('', @lines) eq $str ;
- ok $. == 6;
+ is $., 6;
+ is $io->input_line_number, 6;
ok $io->tell() == length($str) ;
ok $io->eof;
my $io = $UncompressClass->new($name);
ok ! $io->eof;
my @lines = $io->getlines;
+ is $., 1;
+ is $io->input_line_number, 1;
ok $io->eof;
ok @lines == 1 && $lines[0] eq $str;
$io = $UncompressClass->new($name);
ok ! $io->eof;
my $line = $io->getline;
+ is $., 1;
+ is $io->input_line_number, 1;
ok $line eq $str;
ok $io->eof;
}
my $io = $UncompressClass->new($name);
ok ! $io->eof;
my @lines = $io->getlines;
+ is $., 2;
+ is $io->input_line_number, 2;
ok $io->eof;
ok @lines == 2
or print "# exected 2 lines, got " . scalar(@lines) . "\n";
$err++ if $. != ++$no;
}
+ is $., 3;
+ is $io->input_line_number, 3;
ok $err == 0 ;
ok $io->eof;
+
ok @lines == 3 ;
ok join("-", @lines) eq
"This- is- an example\n" .
ok myGZreadFile($input) eq $first . "\x00" x 10 . $last ;
my $io = $UncompressClass->new($input, Strict => 1);
- ok $io->seek(length($first), SEEK_CUR) ;
+ ok $io->seek(length($first), SEEK_CUR)
+ or diag $$UnError ;
ok ! $io->eof;
is $io->tell(), length($first);
+