5
use constant TEST_CASES => {
13
use Test::More tests => 3 + (9 * 5);
15
use_ok('Graphics::ColorNames', (qw(tuple2hex)));
17
my $rgb = Graphics::ColorNames->new(qw( X ));
19
ok($rgb->isa('Graphics::ColorNames'));
21
my $tests = TEST_CASES;
23
foreach my $name (keys %$tests) {
25
my $a = $rgb->hex($name, '0x');
26
ok( $a =~ /^0x[0-9a-f]{6}$/i );
27
ok( eval($a) == $tests->{$name}, "Testing color $name" );
29
my $b = $rgb->hex($name, '#');
30
ok( $b =~ /^\x23[0-9a-f]{6}$/i );
32
my $c = $rgb->hex($name, "");
33
ok( $c =~ /^[0-9a-f]{6}$/i );
35
$c = $rgb->hex($name);
36
ok( $c =~ /^[0-9a-f]{6}$/i );
38
my $d = $rgb->rgb($name, ',');
39
ok( $d =~ /^\d{1,3}(\,\d{1,3}){2}$/ );
41
my @v = $rgb->rgb($name);
44
ok( join(',', @v) eq $d );
45
ok( tuple2hex(@v) eq $c );