Skip to content
Browse files

Commiting the Test-GD module

  • Loading branch information...
1 parent b95a7c9 commit c134e8333ee432bda8b05e15777f2d721bfe19fb Stevan Little committed Dec 4, 2005
Showing with 199 additions and 0 deletions.
  1. +5 −0 Changes
  2. +8 −0 MANIFEST
  3. +8 −0 Makefile.PL
  4. +29 −0 README
  5. +96 −0 lib/Test/GD.pm
  6. +11 −0 t/10_Test_GD_test.t
  7. +20 −0 t/20_cmp_image.t
  8. BIN t/cpan.gif
  9. BIN t/download_perl.gif
  10. +11 −0 t/pod.t
  11. +11 −0 t/pod_coverage.t
View
5 Changes
@@ -0,0 +1,5 @@
+Revision history for Perl extension Test-GD.
+
+0.01 Sat Dec 3 23:06:56 2005
+ - module created
+
View
8 MANIFEST
@@ -0,0 +1,8 @@
+Changes
+Makefile.PL
+MANIFEST
+README
+lib/Test/GD.pm
+t/10_Test_GD_test.t
+t/pod.t
+t/pod_coverage.t
View
8 Makefile.PL
@@ -0,0 +1,8 @@
+use ExtUtils::MakeMaker;
+WriteMakefile(
+ NAME => 'Test::GD',
+ VERSION_FROM => 'lib/Test/GD.pm',
+ PREREQ_PM => {
+ 'Test::More' => 0.47,
+ }
+);
View
29 README
@@ -0,0 +1,29 @@
+Test::GD version 0.01
+===========================
+
+See the individual module documentation for more information
+
+INSTALLATION
+
+To install this module type the following:
+
+ perl Makefile.PL
+ make
+ make test
+ make install
+
+DEPENDENCIES
+
+This module requires these other modules and libraries:
+
+ None
+
+COPYRIGHT AND LICENCE
+
+Copyright (C) 2005 Infinity Interactive, Inc.
+
+http://www.iinteractive.com
+
+This library is free software; you can redistribute it and/or modify
+it under the same terms as Perl itself.
+
View
96 lib/Test/GD.pm
@@ -0,0 +1,96 @@
+
+package Test::GD;
+
+use strict;
+use warnings;
+
+our $VERSION = '0.01';
+
+use Test::Builder ();
+use Scalar::Util 'blessed';
+use GD qw(:cmp);
+
+sub import {
+ my $pkg = caller;
+ no strict 'refs';
+ *{"${pkg}::cmp_image"} = \&cmp_image;
+}
+
+my $Test = Test::Builder->new;
+
+sub cmp_image ($$;$) {
+ my ($got, $expected, $message) = @_;
+ unless (blessed($got) && $got->isa('GD::Image')) {
+ $got = GD::Image->new($got)
+ || die "Could not create GD::Image instance with : $got";
+ }
+ unless (blessed($expected) && $expected->isa('GD::Image')) {
+ $expected = GD::Image->new($expected)
+ || die "Could not create GD::Image instance with : $expected";
+ }
+
+ if ($got->compare($expected) & GD_CMP_IMAGE) {
+ $Test->ok(0, $message);
+ }
+ else {
+ $Test->ok(1, $message);
+ }
+}
+
+1;
+
+__END__
+
+=head1 NAME
+
+Test::GD - A module for testing images using GD
+
+=head1 SYNOPSIS
+
+ use Test::More plan => 1;
+ use Test::GD;
+
+ cmp_image('test.gif', 'control.gif', '... these images should match');
+
+ # or
+ my $test = GD::Image->new('test.gif');
+ my $control = GD::Image->new('control.gif');
+ cmp_image($test, $control, '... these images should match');
+
+=head1 DESCRIPTION
+
+=head1 FUNCTIONS
+
+=over 4
+
+=item B<cmp_image ($got, $expected, $message)>
+
+=back
+
+=head1 TO DO
+
+=head1 BUGS
+
+None that I am aware of. Of course, if you find a bug, let me know, and I will be sure to fix it.
+
+=head1 CODE COVERAGE
+
+I use B<Devel::Cover> to test the code coverage of my tests, below is the B<Devel::Cover> report on this module test suite.
+
+=head1 SEE ALSO
+
+=head1 AUTHOR
+
+stevan little, E<lt>stevan@iinteractive.comE<gt>
+
+=head1 COPYRIGHT AND LICENSE
+
+Copyright 2005 by Infinity Interactive, Inc.
+
+L<http://www.iinteractive.com>
+
+This library is free software; you can redistribute it and/or modify
+it under the same terms as Perl itself.
+
+=cut
+
View
11 t/10_Test_GD_test.t
@@ -0,0 +1,11 @@
+#!/usr/bin/perl
+
+use strict;
+use warnings;
+
+use Test::More no_plan => 1;
+
+BEGIN {
+ use_ok('Test::GD');
+}
+
View
20 t/20_cmp_image.t
@@ -0,0 +1,20 @@
+#!/usr/bin/perl
+
+use strict;
+use warnings;
+
+use Test::Builder::Tester tests => 2;
+use Test::More;
+
+BEGIN {
+ use_ok('Test::GD');
+}
+
+test_out("ok 1 - ... these are the same images");
+test_out("not ok 2 - ... these are not the same images");
+test_err("# Failed test (t/20_cmp_image.t at line 18)");
+
+cmp_image('t/cpan.gif', 't/cpan.gif', '... these are the same images');
+cmp_image('t/cpan.gif', 't/download_perl.gif', '... these are not the same images');
+
+test_test("cmp_image works");
View
BIN t/cpan.gif
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN t/download_perl.gif
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
11 t/pod.t
@@ -0,0 +1,11 @@
+#!/usr/bin/perl
+
+use strict;
+use warnings;
+
+use Test::More;
+
+eval "use Test::Pod 1.14";
+plan skip_all => "Test::Pod 1.14 required for testing POD" if $@;
+
+all_pod_files_ok();
View
11 t/pod_coverage.t
@@ -0,0 +1,11 @@
+#!/usr/bin/perl
+
+use strict;
+use warnings;
+
+use Test::More;
+
+eval "use Test::Pod::Coverage 1.04";
+plan skip_all => "Test::Pod::Coverage 1.04 required for testing POD coverage" if $@;
+
+all_pod_coverage_ok();

0 comments on commit c134e83

Please sign in to comment.
Something went wrong with that request. Please try again.