Image-Magick-CommandParser

 view release on metacpan or  search on metacpan

t/test.t  view on Meta::CPAN

use strict;
use warnings;

use File::Spec;
use File::Temp;

use Image::Magick::CommandParser;

use Test::More;

# ------------------------------------------------

my(@test) =
(
{
	command	=> 'convert logo:',
	count	=> 1,
	glob	=> '',
},
{
	command	=> 'convert logo: output.png',
	count	=> 2,
	glob	=> '',
},
{
	command	=> 'convert logo: -size 320x85 output.png',
	count	=> 3,
	glob	=> '',
},
{
	command	=> 'convert logo: -size 320x85 -shade 110x90 output.png',
	count	=> 4,
	glob	=> '',
},
{
	command	=> 'convert logo: -size 320x85 canvas:none -shade 110x90 output.png',
	count	=> 5,
	glob	=> '',
},
{
	command	=> 'convert logo: -size 320x85 ( +clone canvas:none -shade 110x90 ) output.png',
	count	=> 6,
	glob	=> '',
},
{
	command	=> 'convert logo: -size 320x85 ( canvas:none +clone -shade 110x90 ) output.png',
	count	=> 7,
	glob	=> '',
},
{
	command	=> 'convert logo: canvas:none +clone output.png',
	count	=> 8,
	glob	=> '',
},
{
	command	=> 'convert gradient:red-green -gravity East output.png',
	count	=> 9,
	glob	=> '',
},
{
	command	=> 'convert rose.jpg rose.png',
	count	=> 10,
	glob	=> '',
},
{
	command	=> 'convert label.gif -compose Plus button.gif',
	count	=> 11,

t/test.t  view on Meta::CPAN

},
{
	command	=> 'convert - -size 320x85 output.png',
	count	=> 42,
	glob	=> '',
},
{
	command	=> 'convert gif:- -size 320x85 output.png',
	count	=> 43,
	glob	=> '',
},
{
	command	=> 'convert fd:3 -size 320x85 output.png',
	count	=> 44,
	glob	=> '',
},
{
	command	=> 'convert gif:fd:3 -size 320x85 output.png',
	count	=> 45,
	glob	=> '',
},
{
	command	=> 'convert fd:3 png:fd:4 gif:fd:5 fd:6 -append output.png',
	count	=> 46,
	glob	=> '',
},
{
	command	=> 'convert colors/*s*.png -append output.png',
	count	=> 47,
	glob	=> 'convert colors/fuchsia.png colors/silver.png -append output.png',
},
{
	command	=> 'convert label.gif +clone 0,4,5 button.gif',
	count	=> 48,
	glob	=> '',
},
{
	command	=> 'convert label.gif +clone -1 button.gif',
	count	=> 49,
	glob	=> '',
},
{
	command	=> q|convert magick:logo -resize '10000@' wiz10000.png|,
	count	=> 50,
	glob	=> '',
},
{
	command	=> q|convert magick:logo -label '%m:%f %wx%h' logo.png|,
	comment	=> q|See also test 14, which switches " and '|,
	count	=> 51,
	glob	=> '',
},
{
	command	=> 'convert magick:logo -size 320x85 gif:-',
	count	=> 52,
	glob	=> '',
},
);
my($limit)		= shift || 0;
my($maxlevel)	= shift || 'notice';
my($parser)		= Image::Magick::CommandParser -> new(maxlevel => $maxlevel);

my($expected);
my($got);
my($result);

for my $test (@test)
{
	# Use this trick to run the tests one-at-a-time. See scripts/test.sh.

	next if ( ($limit > 0) && ($$test{count} != $limit) );

	$result = $parser -> run(command => $$test{command});

	if ($result == 0)
	{
		$got		= $parser -> result;
		$expected	= $$test{glob} ? $$test{glob} : $$test{command};

		is_deeply($got, $expected, "$$test{count}: $expected");
	}
	else
	{
		die "Test $$test{count} failed to return 0 from run()\n";
	}
}

done_testing;



( run in 0.708 second using v1.01-cache-2.11-cpan-39bf76dae61 )