]> git.imager.perl.org - imager.git/blob - t/t15color.t
9dcccdee2c32cc2817d4c6b047a239ca5f6dc5ec
[imager.git] / t / t15color.t
1 # Before `make install' is performed this script should be runnable with
2 # `make test'. After `make install' it should work as `perl test.pl'
3
4 ######################### We start with some black magic to print on failure.
5
6 # Change 1..1 below to 1..last_test_to_print .
7 # (It may become useful if the test is moved to ./t subdirectory.)
8
9 BEGIN { $| = 1; print "1..4\n"; }
10 END {print "not ok 1\n" unless $loaded;}
11 use Imager;
12 $loaded = 1;
13 print "ok 1\n";
14
15 init_log("testout/t15color.log",1);
16
17 my $c1 = Imager::Color->new(100, 150, 200, 250);
18 print test_col($c1, 100, 150, 200, 250) ? "ok 2\n" : "not ok 2\n";
19 my $c2 = Imager::Color->new(100, 150, 200);
20 print test_col($c2, 100, 150, 200, 255) ? "ok 3\n" : "not ok 3\n";
21 my $c3 = Imager::Color->new("#6496C8");
22 print test_col($c3, 100, 150, 200, 255) ? "ok 4\n" : "not ok 4\n";
23
24 sub test_col {
25   my ($c, $r, $g, $b, $a) = @_;
26   my ($cr, $cg, $cb, $ca) = $c->rgba;
27   return $r == $cr && $g == $cg && $b == $cb && $a == $ca;
28 }
29
30