File: png.t

package info (click to toggle)
libbarcode-code128-perl 2.21-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 116 kB
  • sloc: perl: 374; makefile: 2
file content (49 lines) | stat: -rw-r--r-- 967 bytes parent folder | download | duplicates (4)
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
# -*- CPerl -*-
#
#  test script for generating png files from Barcode::Code128
#
#  Make sure the module loads correctly - if GD is less than 1.20, skip tests
#
#  Lukas Mueller <lam87@cornell.edu>, June 2012

use strict;

use Test::More tests=>294;
use Barcode::Code128 qw(FNC1);

SKIP:
{


     eval { require GD; };

     skip "GD not installed - skipping test", 294 if ($@);

     skip "GD version < 1.20 - no png support", 294 unless $GD::VERSION > 1.20;

     my $code = new Barcode::Code128;

     my $test = $code->png("CODE 128");

     my $good = GD::Image->newFromPng('t/code128.png');
     my $image = GD::Image->newFromPngData($test);

     for (my $x=0; $x< $image->width; $x++)
     {


          my $y = int($image->height()/2);

           my ($r, $g, $b) = $image->rgb($image->getPixel($x, $y));
           my ($R, $G, $B) = $good->rgb($good->getPixel($x, $y));

           ok($r == $R && $g == $G && $b == $B, "color test $x");
      }

 }





#