1Imager::Test(3) User Contributed Perl Documentation Imager::Test(3)
2
3
4
6 Imager::Test - common functions used in testing Imager
7
9 use Imager::Test 'diff_text_with_nul';
10 diff_text_with_nul($test_name, $text1, $text2, @string_options);
11
13 This is a repository of functions used in testing Imager.
14
15 Some functions will only be useful in testing Imager itself, while
16 others should be useful in testing modules that use Imager.
17
18 No functions are exported by default.
19
21 Test functions
22 is_color1($color, $grey, $comment)
23 Tests if the first channel of $color matches $grey.
24
25 is_color3($color, $red, $green, $blue, $comment)
26 Tests if $color matches the given ($red, $green, $blue)
27
28 is_color4($color, $red, $green, $blue, $alpha, $comment)
29 Tests if $color matches the given ($red, $green, $blue, $alpha)
30
31 is_fcolor1($fcolor, $grey, $comment)
32 is_fcolor1($fcolor, $grey, $epsilon, $comment)
33 Tests if $fcolor's first channel is within $epsilon of ($grey).
34 For the first form $epsilon is taken as 0.001.
35
36 is_fcolor3($fcolor, $red, $green, $blue, $comment)
37 is_fcolor3($fcolor, $red, $green, $blue, $epsilon, $comment)
38 Tests if $fcolor's channels are within $epsilon of ($red, $green,
39 $blue). For the first form $epsilon is taken as 0.001.
40
41 is_fcolor4($fcolor, $red, $green, $blue, $alpha, $comment)
42 is_fcolor4($fcolor, $red, $green, $blue, $alpha, $epsilon, $comment)
43 Tests if $fcolor's channels are within $epsilon of ($red, $green,
44 $blue, $alpha). For the first form $epsilon is taken as 0.001.
45
46 is_image($im1, $im2, $comment)
47 Tests if the 2 images have the same content. Both images must be
48 defined, have the same width, height, channels and the same color
49 in each pixel. The color comparison is done at 8-bits per pixel.
50 The color representation such as direct vs paletted, bits per
51 sample are not checked. Equivalent to is_image_similar($im1, $im2,
52 0, $comment).
53
54 is_imaged($im, $im2, $comment)
55 is_imaged($im, $im2, $epsilon, $comment)
56 Tests if the two images have the same content at the double/sample
57 level. $epsilon defaults to the platform DBL_EPSILON multiplied by
58 four.
59
60 is_image_similar($im1, $im2, $maxdiff, $comment)
61 Tests if the 2 images have similar content. Both images must be
62 defined, have the same width, height and channels. The cum of the
63 squares of the differences of each sample are calculated and must
64 be less than or equal to $maxdiff for the test to pass. The color
65 comparison is done at 8-bits per pixel. The color representation
66 such as direct vs paletted, bits per sample are not checked.
67
68 isnt_image($im1, $im2, $comment)
69 Tests that the two images are different. For regressions tests
70 where something (like text output of "0") produced no change, but
71 should have produced a change.
72
73 test_colorf_gpix($im, $x, $y, $expected, $epsilon, $comment)
74 Retrieves the pixel ($x,$y) from the low-level image $im and
75 compares it to the floating point color $expected, with a tolerance
76 of epsilon.
77
78 test_color_gpix($im, $x, $y, $expected, $comment)
79 Retrieves the pixel ($x,$y) from the low-level image $im and
80 compares it to the floating point color $expected.
81
82 test_colorf_glin($im, $x, $y, $pels, $comment)
83 Retrieves the floating point pixels ($x, $y)-[$x+@$pels, $y] from
84 the low level image $im and compares them against @$pels.
85
86 is_color_close3($color, $red, $green, $blue, $tolerance, $comment)
87 Tests if $color's first three channels are within $tolerance of
88 ($red, $green, $blue).
89
90 Test suite functions
91 Functions that perform one or more tests, typically used to test
92 various parts of Imager's implementation.
93
94 image_bounds_checks($im)
95 Attempts to write to various pixel positions outside the edge of
96 the image to ensure that it fails in those locations.
97
98 Any new image type should pass these tests. Does 16 separate
99 tests.
100
101 mask_tests($im, $epsilon)
102 Perform a standard set of mask tests on the OO image $im. Does 24
103 separate tests.
104
105 diff_text_with_nul($test_name, $text1, $text2, @options)
106 Creates 2 test images and writes $text1 to the first image and
107 $text2 to the second image with the string() method. Each call
108 adds 3 "ok"/"not ok" to the output of the test script.
109
110 Extra options that should be supplied include the font and either a
111 color or channel parameter.
112
113 This was explicitly created for regression tests on #21770.
114
115 Helper functions
116 test_image_raw()
117 Returns a 150x150x3 Imager::ImgRaw test image.
118
119 test_image()
120 Returns a 150x150x3 8-bit/sample OO test image.
121
122 test_image_16()
123 Returns a 150x150x3 16-bit/sample OO test image.
124
125 test_image_double()
126 Returns a 150x150x3 double/sample OO test image.
127
128 color_cmp($c1, $c2)
129 Performs an ordering of 3-channel colors (like <=>).
130
131 colorf_cmp($c1, $c2)
132 Performs an ordering of 3-channel floating point colors (like <=>).
133
135 Tony Cook <tony@develop-help.com>
136
137
138
139perl v5.12.3 2011-06-06 Imager::Test(3)