Archive-Lha

 view release on metacpan or  search on metacpan

t/plha.t  view on Meta::CPAN

    }
};

subtest 'directory entries' => sub {
    my $output = `$^X $blib $plhasa v $lha 2>&1`;
    unlike $output, qr/LHD\.pm/, 'No LHD decoder error';
    unlike $output, qr/Can't load/, 'No module loading errors';
};

subtest 'directory trailing slash preserved' => sub {
    plan skip_all => "dir_trailing_slash.lha not found" unless -f $dirslash;
    my $output = `$^X $blib $plha v $dirslash 2>&1`;
    like $output, qr/lhd_dir\//, '-lhd- directory entry has trailing slash';
    like $output, qr/lh0_dir\//, '-lh0- directory entry has trailing slash';
};

subtest 'DOS timestamps' => sub {
    use Archive::Lha::Header::Utils;
    my $epoch = Archive::Lha::Header::Utils::_dostime2utime(0);
    is $epoch, 0, 'All-zero DOS time returns epoch 0';

    $epoch = Archive::Lha::Header::Utils::_dostime2utime(0x5A34B800);
    ok $epoch > 0, 'Valid DOS time returns positive epoch';

    # 0xFB9FF926 is a corrupt timestamp that decodes to year 2105, which
    # overflows 32-bit time_t on Perl builds with ivsize=4 (e.g. armv6l
    # without -Duse64bitint). We only assert no crash; the proper fix for
    # out-of-range timestamps on such systems is a 64-bit Perl build.
    $epoch = eval { Archive::Lha::Header::Utils::_dostime2utime(0xFB9FF926) };
    ok !$@, 'Invalid DOS time does not crash';
};

subtest 'Amiga archive [Amiga] prefix' => sub {
    plan skip_all => "amiga_prefix.lha not found" unless -f $amiga;
    my $output = `$^X $blib $plhasa l $amiga 2>&1`;
    unlike $output, qr/Can't load|Can't locate/, 'No module loading errors';
    like $output, qr/\[Amiga\]/, 'Shows [Amiga] prefix for Amiga archive';
};

subtest 'Amiga archive filenames preserve case' => sub {
    plan skip_all => "amiga_allcaps_preserve.lha not found" unless -f $amiga_uc;
    my $output = `$^X $blib $plhasa v $amiga_uc 2>&1`;
    # AUTHORS, CHANGES, COPYING are all-caps Amiga filenames; the MS-DOS
    # all-caps lowercasing must not apply to Amiga archives
    like $output, qr/\[Amiga\].*AUTHORS/, 'Amiga all-caps filename not lowercased';
};

subtest 'latin-1 filename display' => sub {
    plan skip_all => "Amoric_src.lha not found" unless -f $latin1;
    my $output = `$^X $blib $plha v $latin1 2>&1`;
    unlike $output, qr/Can't load|Can't locate/, 'No module loading errors';
    # Amoric_src.lha is an Amiga archive with latin-1 filenames
    # Auto-detection should pick up iso-8859-15 for Amiga archives
    like $output, qr/\w/, 'Produces output without error';
};

subtest 'latin-1 filename with explicit -fc' => sub {
    plan skip_all => "Amoric_src.lha not found" unless -f $latin1;
    my $output = `$^X $blib $plha -fc iso-8859-15 -tc UTF-8 v $latin1 2>&1`;
    unlike $output, qr/Can't load|Can't locate/, 'No module loading errors';
    like $output, qr/\w/, 'Produces output with explicit charset options';
};

subtest 'truncated archive warning' => sub {
    plan skip_all => "lh5_truncated.lzh not found" unless -f $trunc;
    my $output = `$^X $blib $plha v $trunc 2>&1`;
    like $output, qr/WARNING.*truncated|truncated.*WARNING/i, 'Warns about truncated archive';
};

subtest 'unknown command error' => sub {
    my $output = `$^X $blib $plha zzz $lha 2>&1`;
    like $output, qr/Unknown command/i, 'Shows unknown command error';
    like $output, qr/Usage/i, 'Shows usage after unknown command error';
};

done_testing;



( run in 0.934 second using v1.01-cache-2.11-cpan-6aa56a78535 )