File: rand_image.t

package info (click to toggle)
libdata-random-perl 0.11-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 740 kB
  • ctags: 156
  • sloc: perl: 1,821; sh: 11; makefile: 4
file content (35 lines) | stat: -rwxr-xr-x 634 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
use strict;
use Test::More;

BEGIN { plan tests => 1 }

use lib qw(..);
use Data::Random qw( rand_image );
use File::Spec;

use vars qw( $imagefile );

# Try to load GD
eval q{ use GD };

SKIP: {

    # If the module cannot be loaded, skip tests
    skip('GD not installed', 1) if $@;

    $imagefile = File::Spec->tmpdir() . '/Data_Random_' . time() . '.tmp';

    # Test writing an image to a file
    {
        open( FILE, ">$imagefile" );
        binmode(FILE);
        print FILE rand_image( bgcolor => [ 0, 0, 0 ] );
        close(FILE);

        ok( !( -z $imagefile ) );
    }
}

END {
    unlink($imagefile) if $imagefile;
}