File: 31x11.t

package info (click to toggle)
libconvert-color-perl 0.08-1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 256 kB
  • sloc: perl: 1,546; makefile: 2
file content (42 lines) | stat: -rw-r--r-- 1,171 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
#!/usr/bin/perl

use Convert::Color::X11;
use Convert::Color::RGB8;

require Test::More;

if( eval { Convert::Color::X11->colors; 1 } ) {
   import Test::More tests => 12;
}
else {
   import Test::More skip_all => "Cannot load X11 rgb.txt database";
}

ok( Convert::Color::X11->colors > 0, 'colors is > 0' );

my $red = Convert::Color::X11->new( 'red' );

is( $red->red,   255, 'red red' );
is( $red->green,   0, 'red green' );
is( $red->blue,    0, 'red blue' );

is( $red->name, "red", 'red name' );

is_deeply( [ $red->as_rgb8->rgb8 ], [ 255, 0, 0 ], 'red as_rgb8' );

my $green = Convert::Color->new( 'x11:green' );

is( $green->red,     0, 'green red' );
is( $green->green, 255, 'green green' );
is( $green->blue,    0, 'green blue' );

is( $green->name, "green", 'green name' );

my $white = Convert::Color::RGB8->new( 255, 255, 255 )->as_x11;

# It's not quite guaranteed that this is "white", as some rgb.txt files might
# contain other names with the same value, such as "Gray100"
#   https://rt.cpan.org/Ticket/Display.html?id=66544

isa_ok( $white, "Convert::Color::X11", '$white' );
is_deeply( [ $white->as_rgb8->rgb8 ], [ 255, 255, 255 ], 'white as_rgb8' );