2
2
3
3
use v5.12;
4
4
use warnings;
5
- use Test::More tests => 47 ;
5
+ use Test::More tests => 57 ;
6
6
use Test::Warn;
7
7
8
8
BEGIN { unshift @INC , ' lib' , ' ../lib' }
@@ -15,80 +15,78 @@ is( not($@), 1, 'could load the module');
15
15
is( ref $def , ' Graphics::Toolkit::Color::Space' , ' got tight return value by loading module' );
16
16
is( $def -> name, ' CIEXYZ' , ' color space has right name' );
17
17
is( $def -> dimensions, 3, ' color space has 3 dimensions' );
18
+
19
+ is( ref $def -> in_range([0, 0, 0]), ' ARRAY' , ' check minimal XYZ values are in bounds' );
20
+ is( ref $def -> in_range([0.950, 1, 1.088]), ' ARRAY' , ' check maximal XYZ values' );
21
+ is( ref $def -> in_range([0,0]), ' ' , " XYZ got too few values" );
22
+ is( ref $def -> in_range([0, 0, 0, 0]), ' ' , " XYZ got too many values" );
23
+ is( ref $def -> in_range([-0.1, 0, 0]), ' ' , " X value is too small" );
24
+ is( ref $def -> in_range([1, 0, 0]), ' ' , " X value is too big" );
25
+ is( ref $def -> in_range([0, -0.1, 0]), ' ' , " Y value is too small" );
26
+ is( ref $def -> in_range([0, 1.1, 0]), ' ' , " Y value is too big" );
27
+ is( ref $def -> in_range([0, 0, -.1 ] ), ' ' , " Z value is too small" );
28
+ is( ref $def -> in_range([0, 0, 1.2] ), ' ' , " Z value is too big" );
29
+
18
30
is( $def -> is_array([0,0,0]), 1, ' vector has 3 elements' );
19
31
is( $def -> can_convert(' rgb' ), 1, ' do only convert from and to rgb' );
20
32
is( $def -> can_convert(' RGB' ), 1, ' namespace can be written upper case' );
21
33
is( $def -> is_partial_hash({x => 1, y => 0}), 1, ' found hash with some keys' );
22
34
is( $def -> is_partial_hash({x => 1, z => 0}), 1, ' found hash with some other keys' );
23
35
is( $def -> can_convert(' yiq' ), 0, ' can not convert to yiq' );
24
- my @val = $def -> deformat([' CIEXYZ' , 1, 0, -0.1]);
25
- is( int @val , 3, ' deformated value triplet (vector)' );
26
- is( $val [0], 1, ' first value good' );
27
- is( $val [1], 0, ' second value good' );
28
- is( $val [2], -0.1, ' third value good' );
36
+
37
+ my $val = $def -> deformat([' CIEXYZ' , 1, 0, -0.1]);
38
+ is( int @$val , 3, ' deformated value triplet (vector)' );
39
+ is( $val -> [0], 1, ' first value good' );
40
+ is( $val -> [1], 0, ' second value good' );
41
+ is( $val -> [2], -0.1, ' third value good' );
29
42
is( $def -> format([0,1,0], ' css_string' ), ' ciexyz(0,1,0)' , ' can format css string' );
30
43
31
- my @ xyz = $def -> deconvert( [ 0, 0, 0], ' RGB' );
32
- is( int @xyz , 3, ' converted color black has three XYZ values' );
33
- is( $xyz [0], 0, ' converted color black has computed right X value' );
34
- is( $xyz [1], 0, ' converted color black has computed right Y value' );
35
- is( $xyz [2], 0, ' converted color black has computed right Z value' );
36
-
37
- @ xyz = $def -> deconvert( [ 0.5, 0.5, 0.5], ' RGB' );
38
- is( int @xyz , 3, ' converted color grey has three XYZ values' );
39
- is( close_enough($xyz [0], 0.20344), 1, ' converted color grey has computed right X value' );
40
- is( close_enough($xyz [1], 0.21404), 1, ' converted color grey has computed right Y value' );
41
- is( close_enough($xyz [2], 0.23305), 1, ' converted color grey has computed right Z value' );
42
-
43
- @ xyz = $def -> deconvert( [ 1, 1, 1], ' RGB' );
44
- is( int @xyz , 3, ' converted color white has three XYZ values' );
45
- is( close_enough($xyz [0], 0.95047), 1, ' converted color white has computed right X value' );
46
- is( close_enough($xyz [1], 1), 1, ' converted color white has computed right Y value' );
47
- is( close_enough($xyz [2], 1.08883), 1, ' converted color white has computed right Z value' );
48
-
49
- @ xyz = $def -> deconvert( [ 1, 0, 0.5], ' RGB' );
50
- is( int @xyz , 3, ' converted color pink has three XYZ values' );
51
- is( close_enough($xyz [0], 0.45108), 1, ' converted color pink has computed right X value' );
52
- is( close_enough($xyz [1], 0.22821), 1, ' converted color pink has computed right Y value' );
53
- is( close_enough($xyz [2], 0.22274), 1, ' converted color pink has computed right Z value' );
54
-
55
- my @ rgb = $def -> convert( [0, 0, 0], ' RGB' );
56
- is( int @rgb , 3, ' converted back black with 3 values' );
57
- is( close_enough($rgb [0], 0), 1, ' right red value' );
58
- is( close_enough($rgb [1], 0), 1, ' right green value' );
59
- is( close_enough($rgb [2], 0), 1, ' right blue value' );
60
-
61
- @ rgb = $def -> convert( [0.20344, 0.21404, 0.23305], ' RGB' );
62
- is( int @rgb , 3, ' converted back gray with 3 values' );
63
- is( close_enough($rgb [0], 0.5), 1, ' right red value' );
64
- is( close_enough($rgb [1], 0.5), 1, ' right green value' );
65
- is( close_enough($rgb [2], 0.5), 1, ' right blue value' );
66
-
67
- @ rgb = $def -> convert( [0.95047, 1, 1.08883], ' RGB' );
68
- is( int @rgb , 3, ' converted back gray with 3 values' );
69
- is( close_enough($rgb [0], 1), 1, ' right red value' );
70
- is( close_enough($rgb [1], 1), 1, ' right green value' );
71
- is( close_enough($rgb [2], 1), 1, ' right blue value' );
72
-
73
- @ rgb = $def -> convert( [0.45108, 0.22821, 0.22274], ' RGB' );
74
- is( int @rgb , 3, ' converted back gray with 3 values' );
75
- is( close_enough($rgb [0], 1 ), 1, ' right red value' );
76
- is( close_enough($rgb [1], 0 ), 1, ' right green value' );
77
- is( close_enough($rgb [2], 0.5), 1, ' right blue value' );
44
+ my $ xyz = $def -> deconvert( [ 0, 0, 0], ' RGB' );
45
+ is( int @$ xyz , 3, ' converted color black has three XYZ values' );
46
+ is( $xyz -> [0], 0, ' converted color black has computed right X value' );
47
+ is( $xyz -> [1], 0, ' converted color black has computed right Y value' );
48
+ is( $xyz -> [2], 0, ' converted color black has computed right Z value' );
49
+
50
+ $ xyz = $def -> deconvert( [ 0.5, 0.5, 0.5], ' RGB' );
51
+ is( int @$ xyz , 3, ' converted color grey has three XYZ values' );
52
+ is( close_enough($xyz -> [0], 0.20344), 1, ' converted color grey has computed right X value' );
53
+ is( close_enough($xyz -> [1], 0.21404), 1, ' converted color grey has computed right Y value' );
54
+ is( close_enough($xyz -> [2], 0.23305), 1, ' converted color grey has computed right Z value' );
55
+
56
+ $ xyz = $def -> deconvert( [ 1, 1, 1], ' RGB' );
57
+ is( int @$ xyz , 3, ' converted color white has three XYZ values' );
58
+ is( close_enough($xyz -> [0], 0.95047), 1, ' converted color white has computed right X value' );
59
+ is( close_enough($xyz -> [1], 1), 1, ' converted color white has computed right Y value' );
60
+ is( close_enough($xyz -> [2], 1.08883), 1, ' converted color white has computed right Z value' );
61
+
62
+ $ xyz = $def -> deconvert( [ 1, 0, 0.5], ' RGB' );
63
+ is( int @$ xyz , 3, ' converted color pink has three XYZ values' );
64
+ is( close_enough($xyz -> [0], 0.45108), 1, ' converted color pink has computed right X value' );
65
+ is( close_enough($xyz -> [1], 0.22821), 1, ' converted color pink has computed right Y value' );
66
+ is( close_enough($xyz -> [2], 0.22274), 1, ' converted color pink has computed right Z value' );
67
+
68
+ my $ rgb = $def -> convert( [0, 0, 0], ' RGB' );
69
+ is( int @$ rgb , 3, ' converted back black with 3 values' );
70
+ is( close_enough($rgb -> [0], 0), 1, ' right red value' );
71
+ is( close_enough($rgb -> [1], 0), 1, ' right green value' );
72
+ is( close_enough($rgb -> [2], 0), 1, ' right blue value' );
73
+
74
+ $ rgb = $def -> convert( [0.20344, 0.21404, 0.23305], ' RGB' );
75
+ is( int @$ rgb , 3, ' converted back gray with 3 values' );
76
+ is( close_enough($rgb -> [0], 0.5), 1, ' right red value' );
77
+ is( close_enough($rgb -> [1], 0.5), 1, ' right green value' );
78
+ is( close_enough($rgb -> [2], 0.5), 1, ' right blue value' );
79
+
80
+ $ rgb = $def -> convert( [0.95047, 1, 1.08883], ' RGB' );
81
+ is( int @$ rgb , 3, ' converted back gray with 3 values' );
82
+ is( close_enough($rgb -> [0], 1), 1, ' right red value' );
83
+ is( close_enough($rgb -> [1], 1), 1, ' right green value' );
84
+ is( close_enough($rgb -> [2], 1), 1, ' right blue value' );
85
+
86
+ $ rgb = $def -> convert( [0.45108, 0.22821, 0.22274], ' RGB' );
87
+ is( int @$ rgb , 3, ' converted back gray with 3 values' );
88
+ is( close_enough($rgb -> [0], 1 ), 1, ' right red value' );
89
+ is( close_enough($rgb -> [1], 0 ), 1, ' right green value' );
90
+ is( close_enough($rgb -> [2], 0.5), 1, ' right blue value' );
78
91
79
92
exit 0;
80
-
81
-
82
- __END__
83
- ok( !$def->check([0, -0.5959, -0.5227]), 'check YIO values works on lower bound values');
84
- ok( !$def->check([1, 0.5959, 0.5227]), 'check YIO values works on upper bound values');
85
- warning_like {$def->check([0,0])} {carped => qr/needs 3 values/}, "check YIQ got too few values";
86
- warning_like {$def->check([0, 0, 0, 0])} {carped => qr/needs 3 values/}, "check YIQ got too many values";
87
-
88
- is( $def->check([0,0,0]), undef, 'checked neutral values');
89
- warning_like {$def->check([-0.1, 0, 0])} {carped => qr/luminance value is below/}, "luminance value is too small";
90
- warning_like {$def->check([ 1.1, 0,0])} {carped => qr/luminance value is above/}, "luminance value is too big";
91
- warning_like {$def->check([0, -0.6, 0])} {carped => qr/in-phase value is below/}, "whiteness value is too small";
92
- warning_like {$def->check([0, 0.6,0])} {carped => qr/in-phase value is above/}, "whiteness value is too big";
93
- warning_like {$def->check([0,0, -0.53 ])} {carped => qr/quadrature value is below/},"quadrature value is too small";
94
- warning_like {$def->check([0,0, 0.53])} {carped => qr/quadrature value is above/}, "quadrature value is too big";
0 commit comments