File: 00_basics.t

package info (click to toggle)
libimage-info-perl 1.45-1
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 940 kB
  • sloc: perl: 3,539; makefile: 12
file content (66 lines) | stat: -rw-r--r-- 1,498 bytes parent folder | download | duplicates (7)
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#!/usr/bin/perl -w

use Test::More;
use strict;
use File::Spec;

# test exporting of functions plus the basics

BEGIN
   {
   plan tests => 11;
   chdir 't' if -d 't';
   use lib '../lib';
   use_ok ("Image::Info") or die($@);
   };

use Image::Info qw(image_info dim html_dim determine_file_format image_type);

my $test = File::Spec->catfile( File::Spec->updir(), 'img', 'test.gif');

my $info = image_info($test);

#############################################################################
# dim, html_dim

my @dim = dim($info);

is (join(" ", @dim), "200 150", 'dim()');

is (dim($info), '200x150', 'dim($info)');

is (html_dim($info), 'width="200" height="150"', 'html_dim()');

is (html_dim(image_info('README')), '', 'no README in info');

#############################################################################
# image_type

my $type = image_type($test);

if (is (ref($type), 'HASH', 'got hash from image_type'))
  {
  is ($type->{file_type}, 'GIF', 'image_type is GIF');
  }
else
  {
  fail ('image_type');
  }

$type = image_type($test.'non-existant');

if (is (ref($type), 'HASH', 'got hash from image_type'))
  {
  ok (exists $type->{error}, '{error} got set');
  ok (exists $type->{Errno}, '{Errno} got set');
  }
else
  {
  fail ('image_type with error');
  fail ('image_type with error');
  }

#############################################################################
# determine_file_format

is (determine_file_format('GIF87a'), 'GIF', 'determine_file_format is GIF');