File: png_barcode.t

package info (click to toggle)
libbusiness-isbn-perl 3.003-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 1,412 kB
  • ctags: 89
  • sloc: perl: 647; makefile: 7
file content (41 lines) | stat: -rw-r--r-- 882 bytes parent folder | download | duplicates (5)
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
#!/usr/bin/perl
use strict;

use Test::More;

my $loaded  = eval { require GD::Barcode::EAN13 };

my $GD_okay = eval { GD::Font->Small };

unless( $loaded )
	{
	plan( skip_all => "You need GD::Barcode::EAN13 to make barcodes" );
	}
elsif( not $GD_okay )
	{
	# This is something that should be caught in GD::Barcode::EAN13
	plan( skip_all => "GD is missing GD::Font->Small. Can't continue." );
	}
else
	{
	plan( tests => 8 );
	
	my $class = 'Business::ISBN';
	
	use_ok( $class );
	
	ok( defined &Business::ISBN::png_barcode, "Method defined" );
		
	foreach my $num ( qw( 0596527241 9780596527242 ) )
		{
		my $isbn = Business::ISBN->new( $num );
		isa_ok( $isbn, $class );
		
		ok( $isbn->is_valid, "Valid ISBN" );
						
		my $png  = eval { $isbn->png_barcode };
		my $at = $@;
		ok( defined $png, "PNG defined for $num" );
		diag( "Eval error for $num: $at" ) if length $at;
		}
	}