File: gif.t

package info (click to toggle)
libbarcode-code128-perl 2.21-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, sid, trixie
  • size: 116 kB
  • sloc: perl: 374; makefile: 2
file content (35 lines) | stat: -rw-r--r-- 807 bytes parent folder | download | duplicates (3)
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
# -*- CPerl -*-

use lib 'lib/';
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 and < 2.18 - use png", 294
         unless ($GD::VERSION < 1.20 or $GD::VERSION >= 2.18);

     my $code = new Barcode::Code128;

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

     my $good = GD::Image->newFromGif('t/code128.gif');
     my $image = GD::Image->newFromGifData($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");


     }
}