in reply to Re: Testing image output
in thread Testing image output
Thanks hippo
I've used md5_hex from Digest::MD5 and checked it is installed as I've required Perl 5.010
Could I please have some feedback on this test file as testing is not my strongest skill...
#!perl use 5.010; use strict; use warnings; use Test::More; eval "use Digest::MD5 qw(md5_hex)"; plan skip_all => "Skipping tests: Digest::MD5 qw(md5) not available!" +if $@; plan tests => 11; use Image::Square; # Hashes of visually tested images my %hash = ( 'hor_square' => '370f26d5fbc52ae93b1bd0928e38cd24', 'hor_left' => '807f6263746b7646f172b7b0928d9195', 'hor_right' => '65672407acff93b188d24bc9b0003bd7', 'ver_square' => 'c9958ec55ef446c41fdecb71b2c69d09', 'ver_top' => '024a3f36e32f1ad193e761b315e7be4c', 'ver_bottom' => 'aea5e4120e8459b226ea003a0d57a2b4', ); # Test horizontal iamge my $image = Image::Square->new('t/CoventryCathedral.jpg'); ok ($image, 'Instantiation'); diag('Testing horizontal image'); my $square1 = $image->square(); my $square2 = $image->square(100); my $square3 = $image->square(150, 0); my $square4 = $image->square(150, 1); ok ($square1->width == $square1->height, 'Image is square from horizon +tal'); ok ( 100 == $square2->width && 100 == $square2->height, 'Correct resiz +e from horizontal'); ok ( md5_hex($square2->jpeg(50)) eq $hash{'hor_square'}, 'Correct cent +re image from horizontal'); ok ( md5_hex($square3->jpeg(50)) eq $hash{'hor_left'}, 'Correct left i +mage from horizontal'); ok ( md5_hex($square4->jpeg(50)) eq $hash{'hor_right'}, 'Correct right + image from horizontal'); # Test vertical iamge $image = Image::Square->new('t/decoration.jpg'); diag('Testing vertical image'); my $square5 = $image->square(); my $square6 = $image->square(100); my $square7 = $image->square(150, 0); my $square8 = $image->square(150, 1); ok ($square5->width == $square5->height, 'Image is square from vertica +l'); ok ($square6->width == 100 && $square6->height == 100, 'Correct resize + from vertical'); ok ( md5_hex($square6->jpeg(50)) eq $hash{'ver_square'}, 'Correct cent +re image from vertical'); ok ( md5_hex($square7->jpeg(50)) eq $hash{'ver_top'}, 'Correct top ima +ge from vertical'); ok ( md5_hex($square8->jpeg(50)) eq $hash{'ver_bottom'}, 'Correct bott +om image from vertical'); done_testing;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Testing image output
by eyepopslikeamosquito (Archbishop) on Sep 08, 2023 at 14:37 UTC | |
by Bod (Parson) on Sep 08, 2023 at 23:22 UTC | |
by Bod (Parson) on Sep 13, 2023 at 21:55 UTC | |
by hippo (Archbishop) on Sep 13, 2023 at 23:05 UTC | |
|
Re^3: Testing image output
by Anonymous Monk on Sep 08, 2023 at 10:48 UTC | |
by Bod (Parson) on Sep 08, 2023 at 23:17 UTC | |
by Anonymous Monk on Sep 09, 2023 at 11:23 UTC |