I have a package MyImage.pm in which there is a function. I need to write tests for this function.
sub get_image_info {
my ($file_name) = @_;
return ('', 0, 0) unless -e $file_name;
my @type = split /\./, $file_name;
my $image = GD::Image->new($file_name);
my $width = $image->width;
my $height = $image->height;
return ($type[-1], $width, $height);
}
1;
use v5.30;
use warnings;
use Test::More;
use MyImage;
BEGIN {use_ok('MyImage', qw( get_image_info)); }
subtest 'get_image_info' => sub {
my $file_name = "aaa" ;
is(get_image_info($file_name), , "aaa");
};
done_testing();