/
02-magickwand.t
48 lines (37 loc) · 990 Bytes
/
02-magickwand.t
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
use v6;
use Test;
use lib 'lib';
plan 6;
use MagickWand;
constant IMAGE-FILENAME = "t/images/aero1.jpg";
{
my $o = MagickWand.new;
ok $o.defined, "MagicWand.new worked";
ok !$o.handle.defined, ".handle is not defined by default";
LEAVE {
$o.cleanup if $o.defined;
}
}
{
my $o = MagickWand.new;
ok $o.read(IMAGE-FILENAME), "read() works";
ok !$o.read("not-found.jpg"), "read() fails gracefully for non-existant files";
my $temp-file-name = "temp.png";
ok $o.write($temp-file-name), "write() works";
ok $temp-file-name.IO ~~ :e, "write() output file exists";
LEAVE {
$o.cleanup if $o.defined;
$temp-file-name.IO.unlink if $temp-file-name.defined;
}
}
=begin stash
{
my $o = MagickWand.new;
my Buf $buffer = IMAGE-FILENAME.IO.slurp(:bin);
ok $o.read-buffer($buffer), "read-buffer works";
ok !$o.read-buffer(Nil), "read-buffer fails gracefully for undefined blob";
LEAVE {
$o.cleanup if $o.defined;
}
}
=end stash