File: 16_stream.t

package info (click to toggle)
libwx-perl 0.9702-1
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 3,240 kB
  • ctags: 1,812
  • sloc: cpp: 8,988; perl: 6,366; makefile: 38; ansic: 1
file content (47 lines) | stat: -rwxr-xr-x 1,011 bytes parent folder | download
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
#!/usr/bin/perl -w

use strict;
use Wx qw(wxBITMAP_TYPE_ICO);
use lib './t';
use Test::More 'tests' => 6;
use Fatal qw(open);

my $app = Wx::SimpleApp->new;
Wx::InitAllImageHandlers;

sub _slurp {
    local $/;
    open my $fh, '< :raw', $_[0];
    return <$fh>;
}

# plain Perl handle (file)
{
    open my $fh, '< :raw', 'wxpl.ico';
    my $img = Wx::Image->new( $fh, wxBITMAP_TYPE_ICO );
    ok( $img->Ok );
    is( $img->GetWidth, 32 );
}

# in-memory file (uses PerlIO, hasn't a filehandle
SKIP: {
    skip 'Perl 5.8 required', 2 if $] < 5.008;

    my $data = _slurp( 'wxpl.ico' );
    open my $fh, '<', \$data;
    my $img = Wx::Image->new( $fh, wxBITMAP_TYPE_ICO );
    ok( $img->Ok );
    is( $img->GetWidth, 32 );
}

# Tied filehandle
SKIP: {
    eval { require IO::String };
    skip 'IO::String required', 2 if $@;

    my $data = _slurp( 'wxpl.ico' );
    my $fh = IO::String->new( $data );
    my $img = Wx::Image->new( $fh, wxBITMAP_TYPE_ICO );
    ok( $img->Ok );
    is( $img->GetWidth, 32 );
}