1Imager::Test(3)       User Contributed Perl Documentation      Imager::Test(3)
2
3
4

NAME

6       Imager::Test - common functions used in testing Imager
7

SYNOPSIS

9         use Imager::Test 'diff_text_with_nul';
10         diff_text_with_nul($test_name, $text1, $text2, @string_options);
11

DESCRIPTION

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

FUNCTIONS

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 sum 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       std_font_tests({ font => $font })
116           Perform standard font interface tests.
117
118       std_font_test_count()
119           The number of tests performed by std_font_tests().
120
121   Helper functions
122       test_image_raw()
123           Returns a 150x150x3 Imager::ImgRaw test image.
124
125       test_image()
126           Returns a 150x150x3 8-bit/sample OO test image. Name: "basic".
127
128       test_image_16()
129           Returns a 150x150x3 16-bit/sample OO test image. Name: "basic16"
130
131       test_image_double()
132           Returns a 150x150x3 double/sample OO test image. Name:
133           "basic_double".
134
135       test_image_gray()
136           Returns a 150x150 single channel OO test image. Name: "gray".
137
138       test_image_gray_16()
139           Returns a 150x150 16-bit/sample single channel OO test image. Name:
140           "gray16".
141
142       test_image_mono()
143           Returns a 150x150 bilevel image that passes the is_bilevel() test.
144           Name: "mono".
145
146       test_image_named($name)
147           Return one of the other test images above based on name.
148
149       color_cmp($c1, $c2)
150           Performs an ordering of 3-channel colors (like <=>).
151
152       colorf_cmp($c1, $c2)
153           Performs an ordering of 3-channel floating point colors (like <=>).
154

AUTHOR

156       Tony Cook <tony@develop-help.com>
157
158
159
160perl v5.30.0                      2019-07-26                   Imager::Test(3)
Impressum