1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52
|
use strict;
use warnings;
use Test::More tests => 2;
use File::Temp qw( tempdir );
use File::Spec;
use Archive::Ar;
my $dir = tempdir( CLEANUP => 1 );
note "dir = $dir";
my %data = (
foo => "something completely different",
bar => "something the same",
baz => "Truck, not monkey",
);
for my $name (keys %data) {
open(my $fh, '>', File::Spec->catfile($dir, "$name.txt"));
print $fh $data{$name};
close $fh;
}
subtest 'add list' => sub {
plan tests => 4;
my $ar = Archive::Ar->new;
my $count = $ar->add_files(map { File::Spec->catfile($dir, "$_.txt") }
qw( foo bar baz ));
is $count, 3, 'add_files';
for my $name (qw( foo bar baz )) {
is $ar->get_content("$name.txt")->{data}, $data{$name}, "data for $name";
}
};
subtest 'add ref' => sub {
plan tests => 4;
my $ar = Archive::Ar->new;
my $count = $ar->add_files(map { File::Spec->catfile($dir, "$_.txt") }
qw( foo bar baz ));
is $count, 3, 'add_files';
for my $name (qw( foo bar baz )) {
is $ar->get_content("$name.txt")->{data}, $data{$name}, "data for $name";
}
};
|