1 | /*
|
---|
2 | * Copyright (c) 2019 Jiri Svoboda
|
---|
3 | * All rights reserved.
|
---|
4 | *
|
---|
5 | * Redistribution and use in source and binary forms, with or without
|
---|
6 | * modification, are permitted provided that the following conditions
|
---|
7 | * are met:
|
---|
8 | *
|
---|
9 | * - Redistributions of source code must retain the above copyright
|
---|
10 | * notice, this list of conditions and the following disclaimer.
|
---|
11 | * - Redistributions in binary form must reproduce the above copyright
|
---|
12 | * notice, this list of conditions and the following disclaimer in the
|
---|
13 | * documentation and/or other materials provided with the distribution.
|
---|
14 | * - The name of the author may not be used to endorse or promote products
|
---|
15 | * derived from this software without specific prior written permission.
|
---|
16 | *
|
---|
17 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
---|
18 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
---|
19 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
---|
20 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
---|
21 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
---|
22 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
---|
23 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
---|
24 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
---|
25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
---|
26 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
---|
27 | */
|
---|
28 |
|
---|
29 | #include <gfx/coord.h>
|
---|
30 | #include <pcut/pcut.h>
|
---|
31 |
|
---|
32 | PCUT_INIT;
|
---|
33 |
|
---|
34 | PCUT_TEST_SUITE(coord);
|
---|
35 |
|
---|
36 | /** gfx_coord_div_rneg rounds towards negative numbers */
|
---|
37 | PCUT_TEST(coord_div_rneg)
|
---|
38 | {
|
---|
39 | PCUT_ASSERT_INT_EQUALS(-3, gfx_coord_div_rneg(-7, 3));
|
---|
40 | PCUT_ASSERT_INT_EQUALS(-2, gfx_coord_div_rneg(-6, 3));
|
---|
41 | PCUT_ASSERT_INT_EQUALS(-2, gfx_coord_div_rneg(-5, 3));
|
---|
42 | PCUT_ASSERT_INT_EQUALS(-2, gfx_coord_div_rneg(-4, 3));
|
---|
43 | PCUT_ASSERT_INT_EQUALS(-1, gfx_coord_div_rneg(-3, 3));
|
---|
44 | PCUT_ASSERT_INT_EQUALS(-1, gfx_coord_div_rneg(-2, 3));
|
---|
45 | PCUT_ASSERT_INT_EQUALS(-1, gfx_coord_div_rneg(-1, 3));
|
---|
46 | PCUT_ASSERT_INT_EQUALS(0, gfx_coord_div_rneg(0, 3));
|
---|
47 | PCUT_ASSERT_INT_EQUALS(0, gfx_coord_div_rneg(1, 3));
|
---|
48 | PCUT_ASSERT_INT_EQUALS(0, gfx_coord_div_rneg(2, 3));
|
---|
49 | PCUT_ASSERT_INT_EQUALS(1, gfx_coord_div_rneg(3, 3));
|
---|
50 | PCUT_ASSERT_INT_EQUALS(1, gfx_coord_div_rneg(4, 3));
|
---|
51 | PCUT_ASSERT_INT_EQUALS(1, gfx_coord_div_rneg(5, 3));
|
---|
52 | PCUT_ASSERT_INT_EQUALS(2, gfx_coord_div_rneg(6, 3));
|
---|
53 | }
|
---|
54 |
|
---|
55 | /** gfx_coord2_add should add two coordinate vectors */
|
---|
56 | PCUT_TEST(coord2_add)
|
---|
57 | {
|
---|
58 | gfx_coord2_t a, b;
|
---|
59 | gfx_coord2_t d;
|
---|
60 |
|
---|
61 | a.x = 10;
|
---|
62 | a.y = 11;
|
---|
63 | b.x = 20;
|
---|
64 | b.y = 22;
|
---|
65 |
|
---|
66 | gfx_coord2_add(&a, &b, &d);
|
---|
67 |
|
---|
68 | PCUT_ASSERT_INT_EQUALS(a.x + b.x, d.x);
|
---|
69 | PCUT_ASSERT_INT_EQUALS(a.y + b.y, d.y);
|
---|
70 | }
|
---|
71 |
|
---|
72 | /** gfx_coord2_subtract should subtract two coordinate vectors */
|
---|
73 | PCUT_TEST(coord2_subtract)
|
---|
74 | {
|
---|
75 | gfx_coord2_t a, b;
|
---|
76 | gfx_coord2_t d;
|
---|
77 |
|
---|
78 | a.x = 10;
|
---|
79 | a.y = 11;
|
---|
80 | b.x = 20;
|
---|
81 | b.y = 22;
|
---|
82 |
|
---|
83 | gfx_coord2_subtract(&a, &b, &d);
|
---|
84 |
|
---|
85 | PCUT_ASSERT_INT_EQUALS(a.x - b.x, d.x);
|
---|
86 | PCUT_ASSERT_INT_EQUALS(a.y - b.y, d.y);
|
---|
87 | }
|
---|
88 |
|
---|
89 | /** gfx_coord2_clip with point to lower-left of clipping rectangle */
|
---|
90 | PCUT_TEST(coord2_clip_ll)
|
---|
91 | {
|
---|
92 | gfx_coord2_t p;
|
---|
93 | gfx_coord2_t cp;
|
---|
94 | gfx_rect_t rect;
|
---|
95 |
|
---|
96 | p.x = 1;
|
---|
97 | p.y = 2;
|
---|
98 |
|
---|
99 | rect.p0.x = 3;
|
---|
100 | rect.p0.y = 4;
|
---|
101 | rect.p1.x = 5;
|
---|
102 | rect.p1.y = 6;
|
---|
103 |
|
---|
104 | gfx_coord2_clip(&p, &rect, &cp);
|
---|
105 |
|
---|
106 | PCUT_ASSERT_INT_EQUALS(3, cp.x);
|
---|
107 | PCUT_ASSERT_INT_EQUALS(4, cp.y);
|
---|
108 | }
|
---|
109 |
|
---|
110 | /** gfx_coord2_clip with point inside the clipping rectangle */
|
---|
111 | PCUT_TEST(coord2_clip_mm)
|
---|
112 | {
|
---|
113 | gfx_coord2_t p;
|
---|
114 | gfx_coord2_t cp;
|
---|
115 | gfx_rect_t rect;
|
---|
116 |
|
---|
117 | p.x = 2;
|
---|
118 | p.y = 3;
|
---|
119 |
|
---|
120 | rect.p0.x = 1;
|
---|
121 | rect.p0.y = 2;
|
---|
122 | rect.p1.x = 3;
|
---|
123 | rect.p1.y = 4;
|
---|
124 |
|
---|
125 | gfx_coord2_clip(&p, &rect, &cp);
|
---|
126 |
|
---|
127 | PCUT_ASSERT_INT_EQUALS(2, cp.x);
|
---|
128 | PCUT_ASSERT_INT_EQUALS(3, cp.y);
|
---|
129 | }
|
---|
130 |
|
---|
131 | /** gfx_coord2_clip with point to upper-right of clipping rectangle */
|
---|
132 | PCUT_TEST(coord2_clip_hh)
|
---|
133 | {
|
---|
134 | gfx_coord2_t p;
|
---|
135 | gfx_coord2_t cp;
|
---|
136 | gfx_rect_t rect;
|
---|
137 |
|
---|
138 | p.x = 5;
|
---|
139 | p.y = 6;
|
---|
140 |
|
---|
141 | rect.p0.x = 1;
|
---|
142 | rect.p0.y = 2;
|
---|
143 | rect.p1.x = 3;
|
---|
144 | rect.p1.y = 4;
|
---|
145 |
|
---|
146 | gfx_coord2_clip(&p, &rect, &cp);
|
---|
147 |
|
---|
148 | PCUT_ASSERT_INT_EQUALS(2, cp.x);
|
---|
149 | PCUT_ASSERT_INT_EQUALS(3, cp.y);
|
---|
150 | }
|
---|
151 |
|
---|
152 | /** gfx_coord2_project projects pixel from one rectangle to another */
|
---|
153 | PCUT_TEST(coord2_project)
|
---|
154 | {
|
---|
155 | gfx_coord2_t a, d;
|
---|
156 | gfx_rect_t srect, drect;
|
---|
157 |
|
---|
158 | srect.p0.x = 10;
|
---|
159 | srect.p0.y = 10;
|
---|
160 | srect.p1.x = 20 + 1;
|
---|
161 | srect.p1.y = 20 + 1;
|
---|
162 |
|
---|
163 | drect.p0.x = 100;
|
---|
164 | drect.p0.y = 100;
|
---|
165 | drect.p1.x = 200 + 1;
|
---|
166 | drect.p1.y = 200 + 1;
|
---|
167 |
|
---|
168 | a.x = 10;
|
---|
169 | a.y = 10;
|
---|
170 | gfx_coord2_project(&a, &srect, &drect, &d);
|
---|
171 | PCUT_ASSERT_INT_EQUALS(100, d.x);
|
---|
172 | PCUT_ASSERT_INT_EQUALS(100, d.y);
|
---|
173 |
|
---|
174 | a.x = 15;
|
---|
175 | a.y = 15;
|
---|
176 | gfx_coord2_project(&a, &srect, &drect, &d);
|
---|
177 | PCUT_ASSERT_INT_EQUALS(150, d.x);
|
---|
178 | PCUT_ASSERT_INT_EQUALS(150, d.y);
|
---|
179 |
|
---|
180 | a.x = 12;
|
---|
181 | a.y = 16;
|
---|
182 | gfx_coord2_project(&a, &srect, &drect, &d);
|
---|
183 | PCUT_ASSERT_INT_EQUALS(120, d.x);
|
---|
184 | PCUT_ASSERT_INT_EQUALS(160, d.y);
|
---|
185 |
|
---|
186 | a.x = 20;
|
---|
187 | a.y = 20;
|
---|
188 | gfx_coord2_project(&a, &srect, &drect, &d);
|
---|
189 | PCUT_ASSERT_INT_EQUALS(200, d.x);
|
---|
190 | PCUT_ASSERT_INT_EQUALS(200, d.y);
|
---|
191 | }
|
---|
192 |
|
---|
193 | /** gfx_rect_translate should translate rectangle */
|
---|
194 | PCUT_TEST(rect_translate)
|
---|
195 | {
|
---|
196 | gfx_coord2_t offs;
|
---|
197 | gfx_rect_t srect;
|
---|
198 | gfx_rect_t drect;
|
---|
199 |
|
---|
200 | offs.x = 5;
|
---|
201 | offs.y = 6;
|
---|
202 |
|
---|
203 | srect.p0.x = 10;
|
---|
204 | srect.p0.y = 11;
|
---|
205 | srect.p1.x = 20;
|
---|
206 | srect.p1.y = 22;
|
---|
207 |
|
---|
208 | gfx_rect_translate(&offs, &srect, &drect);
|
---|
209 |
|
---|
210 | PCUT_ASSERT_INT_EQUALS(offs.x + srect.p0.x, drect.p0.x);
|
---|
211 | PCUT_ASSERT_INT_EQUALS(offs.y + srect.p0.y, drect.p0.y);
|
---|
212 | PCUT_ASSERT_INT_EQUALS(offs.x + srect.p1.x, drect.p1.x);
|
---|
213 | PCUT_ASSERT_INT_EQUALS(offs.y + srect.p1.y, drect.p1.y);
|
---|
214 | }
|
---|
215 |
|
---|
216 | /** gfx_rect_rtranslate should reverse-translate rectangle */
|
---|
217 | PCUT_TEST(rect_rtranslate)
|
---|
218 | {
|
---|
219 | gfx_coord2_t offs;
|
---|
220 | gfx_rect_t srect;
|
---|
221 | gfx_rect_t drect;
|
---|
222 |
|
---|
223 | offs.x = 5;
|
---|
224 | offs.y = 6;
|
---|
225 |
|
---|
226 | srect.p0.x = 10;
|
---|
227 | srect.p0.y = 11;
|
---|
228 | srect.p1.x = 20;
|
---|
229 | srect.p1.y = 22;
|
---|
230 |
|
---|
231 | gfx_rect_rtranslate(&offs, &srect, &drect);
|
---|
232 |
|
---|
233 | PCUT_ASSERT_INT_EQUALS(srect.p0.x - offs.x, drect.p0.x);
|
---|
234 | PCUT_ASSERT_INT_EQUALS(srect.p0.y - offs.y, drect.p0.y);
|
---|
235 | PCUT_ASSERT_INT_EQUALS(srect.p1.x - offs.x, drect.p1.x);
|
---|
236 | PCUT_ASSERT_INT_EQUALS(srect.p1.y - offs.y, drect.p1.y);
|
---|
237 | }
|
---|
238 |
|
---|
239 | /** Sorting span with lower start and higher end point results in the same span. */
|
---|
240 | PCUT_TEST(span_points_sort_asc)
|
---|
241 | {
|
---|
242 | gfx_coord_t a, b;
|
---|
243 |
|
---|
244 | gfx_span_points_sort(1, 2, &a, &b);
|
---|
245 | PCUT_ASSERT_INT_EQUALS(1, a);
|
---|
246 | PCUT_ASSERT_INT_EQUALS(2, b);
|
---|
247 | }
|
---|
248 |
|
---|
249 | /** Sorting span with same start and end point results in the same span. */
|
---|
250 | PCUT_TEST(span_points_sort_equal)
|
---|
251 | {
|
---|
252 | gfx_coord_t a, b;
|
---|
253 |
|
---|
254 | gfx_span_points_sort(1, 1, &a, &b);
|
---|
255 | PCUT_ASSERT_INT_EQUALS(1, a);
|
---|
256 | PCUT_ASSERT_INT_EQUALS(1, b);
|
---|
257 | }
|
---|
258 |
|
---|
259 | /** Sorting span with hight start and lower end point results in transposed span. */
|
---|
260 | PCUT_TEST(span_points_sort_desc)
|
---|
261 | {
|
---|
262 | gfx_coord_t a, b;
|
---|
263 |
|
---|
264 | gfx_span_points_sort(1, 0, &a, &b);
|
---|
265 | PCUT_ASSERT_INT_EQUALS(1, a);
|
---|
266 | PCUT_ASSERT_INT_EQUALS(2, b);
|
---|
267 | }
|
---|
268 |
|
---|
269 | /** Rectangle envelope with first rectangle empty should return the second rectangle. */
|
---|
270 | PCUT_TEST(rect_envelope_a_empty)
|
---|
271 | {
|
---|
272 | gfx_rect_t a;
|
---|
273 | gfx_rect_t b;
|
---|
274 | gfx_rect_t e;
|
---|
275 |
|
---|
276 | a.p0.x = 0;
|
---|
277 | a.p0.y = 0;
|
---|
278 | a.p1.x = 0;
|
---|
279 | a.p1.y = 0;
|
---|
280 |
|
---|
281 | b.p0.x = 1;
|
---|
282 | b.p0.y = 2;
|
---|
283 | b.p1.x = 3;
|
---|
284 | b.p1.y = 4;
|
---|
285 |
|
---|
286 | gfx_rect_envelope(&a, &b, &e);
|
---|
287 | PCUT_ASSERT_INT_EQUALS(1, e.p0.x);
|
---|
288 | PCUT_ASSERT_INT_EQUALS(2, e.p0.y);
|
---|
289 | PCUT_ASSERT_INT_EQUALS(3, e.p1.x);
|
---|
290 | PCUT_ASSERT_INT_EQUALS(4, e.p1.y);
|
---|
291 | }
|
---|
292 |
|
---|
293 | /** Rectangle envelope with second rectangle empty should return the first rectangle. */
|
---|
294 | PCUT_TEST(rect_envelope_b_empty)
|
---|
295 | {
|
---|
296 | gfx_rect_t a;
|
---|
297 | gfx_rect_t b;
|
---|
298 | gfx_rect_t e;
|
---|
299 |
|
---|
300 | a.p0.x = 1;
|
---|
301 | a.p0.y = 2;
|
---|
302 | a.p1.x = 3;
|
---|
303 | a.p1.y = 4;
|
---|
304 |
|
---|
305 | b.p0.x = 0;
|
---|
306 | b.p0.y = 0;
|
---|
307 | b.p1.x = 0;
|
---|
308 | b.p1.y = 0;
|
---|
309 |
|
---|
310 | gfx_rect_envelope(&a, &b, &e);
|
---|
311 | PCUT_ASSERT_INT_EQUALS(1, e.p0.x);
|
---|
312 | PCUT_ASSERT_INT_EQUALS(2, e.p0.y);
|
---|
313 | PCUT_ASSERT_INT_EQUALS(3, e.p1.x);
|
---|
314 | PCUT_ASSERT_INT_EQUALS(4, e.p1.y);
|
---|
315 | }
|
---|
316 |
|
---|
317 | /** Rectangle envelope, a has both coordinates lower than b */
|
---|
318 | PCUT_TEST(rect_envelope_nonempty_a_lt_b)
|
---|
319 | {
|
---|
320 | gfx_rect_t a;
|
---|
321 | gfx_rect_t b;
|
---|
322 | gfx_rect_t e;
|
---|
323 |
|
---|
324 | a.p0.x = 1;
|
---|
325 | a.p0.y = 2;
|
---|
326 | a.p1.x = 3;
|
---|
327 | a.p1.y = 4;
|
---|
328 |
|
---|
329 | b.p0.x = 5;
|
---|
330 | b.p0.y = 6;
|
---|
331 | b.p1.x = 7;
|
---|
332 | b.p1.y = 8;
|
---|
333 |
|
---|
334 | gfx_rect_envelope(&a, &b, &e);
|
---|
335 | PCUT_ASSERT_INT_EQUALS(1, e.p0.x);
|
---|
336 | PCUT_ASSERT_INT_EQUALS(2, e.p0.y);
|
---|
337 | PCUT_ASSERT_INT_EQUALS(7, e.p1.x);
|
---|
338 | PCUT_ASSERT_INT_EQUALS(8, e.p1.y);
|
---|
339 | }
|
---|
340 |
|
---|
341 | /** Rectangle envelope, a has both coordinates higher than b */
|
---|
342 | PCUT_TEST(rect_envelope_nonempty_a_gt_b)
|
---|
343 | {
|
---|
344 | gfx_rect_t a;
|
---|
345 | gfx_rect_t b;
|
---|
346 | gfx_rect_t e;
|
---|
347 |
|
---|
348 | a.p0.x = 5;
|
---|
349 | a.p0.y = 6;
|
---|
350 | a.p1.x = 7;
|
---|
351 | a.p1.y = 8;
|
---|
352 |
|
---|
353 | b.p0.x = 1;
|
---|
354 | b.p0.y = 2;
|
---|
355 | b.p1.x = 3;
|
---|
356 | b.p1.y = 4;
|
---|
357 |
|
---|
358 | gfx_rect_envelope(&a, &b, &e);
|
---|
359 | PCUT_ASSERT_INT_EQUALS(1, e.p0.x);
|
---|
360 | PCUT_ASSERT_INT_EQUALS(2, e.p0.y);
|
---|
361 | PCUT_ASSERT_INT_EQUALS(7, e.p1.x);
|
---|
362 | PCUT_ASSERT_INT_EQUALS(8, e.p1.y);
|
---|
363 | }
|
---|
364 |
|
---|
365 | /** Rectangle envelope, a is inside b */
|
---|
366 | PCUT_TEST(rect_envelope_nonempty_a_inside_b)
|
---|
367 | {
|
---|
368 | gfx_rect_t a;
|
---|
369 | gfx_rect_t b;
|
---|
370 | gfx_rect_t e;
|
---|
371 |
|
---|
372 | a.p0.x = 1;
|
---|
373 | a.p0.y = 2;
|
---|
374 | a.p1.x = 7;
|
---|
375 | a.p1.y = 8;
|
---|
376 |
|
---|
377 | b.p0.x = 3;
|
---|
378 | b.p0.y = 4;
|
---|
379 | b.p1.x = 5;
|
---|
380 | b.p1.y = 6;
|
---|
381 |
|
---|
382 | gfx_rect_envelope(&a, &b, &e);
|
---|
383 | PCUT_ASSERT_INT_EQUALS(1, e.p0.x);
|
---|
384 | PCUT_ASSERT_INT_EQUALS(2, e.p0.y);
|
---|
385 | PCUT_ASSERT_INT_EQUALS(7, e.p1.x);
|
---|
386 | PCUT_ASSERT_INT_EQUALS(8, e.p1.y);
|
---|
387 | }
|
---|
388 |
|
---|
389 | /** Rectangle envelope, b is inside a */
|
---|
390 | PCUT_TEST(rect_envelope_nonempty_b_inside_a)
|
---|
391 | {
|
---|
392 | gfx_rect_t a;
|
---|
393 | gfx_rect_t b;
|
---|
394 | gfx_rect_t e;
|
---|
395 |
|
---|
396 | a.p0.x = 3;
|
---|
397 | a.p0.y = 4;
|
---|
398 | a.p1.x = 5;
|
---|
399 | a.p1.y = 6;
|
---|
400 |
|
---|
401 | b.p0.x = 1;
|
---|
402 | b.p0.y = 2;
|
---|
403 | b.p1.x = 7;
|
---|
404 | b.p1.y = 8;
|
---|
405 |
|
---|
406 | gfx_rect_envelope(&a, &b, &e);
|
---|
407 | PCUT_ASSERT_INT_EQUALS(1, e.p0.x);
|
---|
408 | PCUT_ASSERT_INT_EQUALS(2, e.p0.y);
|
---|
409 | PCUT_ASSERT_INT_EQUALS(7, e.p1.x);
|
---|
410 | PCUT_ASSERT_INT_EQUALS(8, e.p1.y);
|
---|
411 | }
|
---|
412 |
|
---|
413 | /** Rectangle envelope, a and b cross */
|
---|
414 | PCUT_TEST(rect_envelope_nonempty_a_crosses_b)
|
---|
415 | {
|
---|
416 | gfx_rect_t a;
|
---|
417 | gfx_rect_t b;
|
---|
418 | gfx_rect_t e;
|
---|
419 |
|
---|
420 | a.p0.x = 1;
|
---|
421 | a.p0.y = 2;
|
---|
422 | a.p1.x = 4;
|
---|
423 | a.p1.y = 3;
|
---|
424 |
|
---|
425 | b.p0.x = 2;
|
---|
426 | b.p0.y = 1;
|
---|
427 | b.p1.x = 3;
|
---|
428 | b.p1.y = 4;
|
---|
429 |
|
---|
430 | gfx_rect_envelope(&a, &b, &e);
|
---|
431 | PCUT_ASSERT_INT_EQUALS(1, e.p0.x);
|
---|
432 | PCUT_ASSERT_INT_EQUALS(1, e.p0.y);
|
---|
433 | PCUT_ASSERT_INT_EQUALS(4, e.p1.x);
|
---|
434 | PCUT_ASSERT_INT_EQUALS(4, e.p1.y);
|
---|
435 | }
|
---|
436 |
|
---|
437 | /** Clip rectangle with rect completely inside the clipping rectangle */
|
---|
438 | PCUT_TEST(rect_clip_rect_inside)
|
---|
439 | {
|
---|
440 | gfx_rect_t rect;
|
---|
441 | gfx_rect_t clip;
|
---|
442 | gfx_rect_t dest;
|
---|
443 |
|
---|
444 | rect.p0.x = 3;
|
---|
445 | rect.p0.y = 4;
|
---|
446 | rect.p1.x = 5;
|
---|
447 | rect.p1.y = 6;
|
---|
448 |
|
---|
449 | clip.p0.x = 1;
|
---|
450 | clip.p0.y = 2;
|
---|
451 | clip.p1.x = 7;
|
---|
452 | clip.p1.y = 8;
|
---|
453 |
|
---|
454 | gfx_rect_clip(&rect, &clip, &dest);
|
---|
455 | PCUT_ASSERT_INT_EQUALS(3, dest.p0.x);
|
---|
456 | PCUT_ASSERT_INT_EQUALS(4, dest.p0.y);
|
---|
457 | PCUT_ASSERT_INT_EQUALS(5, dest.p1.x);
|
---|
458 | PCUT_ASSERT_INT_EQUALS(6, dest.p1.y);
|
---|
459 | }
|
---|
460 |
|
---|
461 | /** Clip rectangle with rect covering the clipping rectangle */
|
---|
462 | PCUT_TEST(rect_clip_rect_covering)
|
---|
463 | {
|
---|
464 | gfx_rect_t rect;
|
---|
465 | gfx_rect_t clip;
|
---|
466 | gfx_rect_t dest;
|
---|
467 |
|
---|
468 | rect.p0.x = 1;
|
---|
469 | rect.p0.y = 2;
|
---|
470 | rect.p1.x = 7;
|
---|
471 | rect.p1.y = 8;
|
---|
472 |
|
---|
473 | clip.p0.x = 3;
|
---|
474 | clip.p0.y = 4;
|
---|
475 | clip.p1.x = 5;
|
---|
476 | clip.p1.y = 6;
|
---|
477 |
|
---|
478 | gfx_rect_clip(&rect, &clip, &dest);
|
---|
479 | PCUT_ASSERT_INT_EQUALS(3, dest.p0.x);
|
---|
480 | PCUT_ASSERT_INT_EQUALS(4, dest.p0.y);
|
---|
481 | PCUT_ASSERT_INT_EQUALS(5, dest.p1.x);
|
---|
482 | PCUT_ASSERT_INT_EQUALS(6, dest.p1.y);
|
---|
483 | }
|
---|
484 |
|
---|
485 | /** Clip rectangle with rect outside, having lower coordinates */
|
---|
486 | PCUT_TEST(rect_clip_rect_out_ll)
|
---|
487 | {
|
---|
488 | gfx_rect_t rect;
|
---|
489 | gfx_rect_t clip;
|
---|
490 | gfx_rect_t dest;
|
---|
491 |
|
---|
492 | rect.p0.x = 1;
|
---|
493 | rect.p0.y = 2;
|
---|
494 | rect.p1.x = 3;
|
---|
495 | rect.p1.y = 4;
|
---|
496 |
|
---|
497 | clip.p0.x = 5;
|
---|
498 | clip.p0.y = 6;
|
---|
499 | clip.p1.x = 7;
|
---|
500 | clip.p1.y = 8;
|
---|
501 |
|
---|
502 | gfx_rect_clip(&rect, &clip, &dest);
|
---|
503 | PCUT_ASSERT_INT_EQUALS(5, dest.p0.x);
|
---|
504 | PCUT_ASSERT_INT_EQUALS(6, dest.p0.y);
|
---|
505 | PCUT_ASSERT_INT_EQUALS(5, dest.p1.x);
|
---|
506 | PCUT_ASSERT_INT_EQUALS(6, dest.p1.y);
|
---|
507 | }
|
---|
508 |
|
---|
509 | /** Clip rectangle with rect outside, having higher coordinates */
|
---|
510 | PCUT_TEST(rect_clip_rect_out_hh)
|
---|
511 | {
|
---|
512 | gfx_rect_t rect;
|
---|
513 | gfx_rect_t clip;
|
---|
514 | gfx_rect_t dest;
|
---|
515 |
|
---|
516 | rect.p0.x = 5;
|
---|
517 | rect.p0.y = 6;
|
---|
518 | rect.p1.x = 7;
|
---|
519 | rect.p1.y = 8;
|
---|
520 |
|
---|
521 | clip.p0.x = 1;
|
---|
522 | clip.p0.y = 2;
|
---|
523 | clip.p1.x = 3;
|
---|
524 | clip.p1.y = 4;
|
---|
525 |
|
---|
526 | gfx_rect_clip(&rect, &clip, &dest);
|
---|
527 | PCUT_ASSERT_INT_EQUALS(3, dest.p0.x);
|
---|
528 | PCUT_ASSERT_INT_EQUALS(4, dest.p0.y);
|
---|
529 | PCUT_ASSERT_INT_EQUALS(3, dest.p1.x);
|
---|
530 | PCUT_ASSERT_INT_EQUALS(4, dest.p1.y);
|
---|
531 | }
|
---|
532 |
|
---|
533 | /** Clip rectangle with rect partially outside, having lower coordinates */
|
---|
534 | PCUT_TEST(rect_clip_rect_ll)
|
---|
535 | {
|
---|
536 | gfx_rect_t rect;
|
---|
537 | gfx_rect_t clip;
|
---|
538 | gfx_rect_t dest;
|
---|
539 |
|
---|
540 | rect.p0.x = 1;
|
---|
541 | rect.p0.y = 2;
|
---|
542 | rect.p1.x = 5;
|
---|
543 | rect.p1.y = 6;
|
---|
544 |
|
---|
545 | clip.p0.x = 3;
|
---|
546 | clip.p0.y = 4;
|
---|
547 | clip.p1.x = 7;
|
---|
548 | clip.p1.y = 8;
|
---|
549 |
|
---|
550 | gfx_rect_clip(&rect, &clip, &dest);
|
---|
551 | PCUT_ASSERT_INT_EQUALS(3, dest.p0.x);
|
---|
552 | PCUT_ASSERT_INT_EQUALS(4, dest.p0.y);
|
---|
553 | PCUT_ASSERT_INT_EQUALS(5, dest.p1.x);
|
---|
554 | PCUT_ASSERT_INT_EQUALS(6, dest.p1.y);
|
---|
555 | }
|
---|
556 |
|
---|
557 | /** Clip rectangle with rect partially outside, having higher coordinates */
|
---|
558 | PCUT_TEST(rect_clip_rect_hh)
|
---|
559 | {
|
---|
560 | gfx_rect_t rect;
|
---|
561 | gfx_rect_t clip;
|
---|
562 | gfx_rect_t dest;
|
---|
563 |
|
---|
564 | rect.p0.x = 3;
|
---|
565 | rect.p0.y = 4;
|
---|
566 | rect.p1.x = 7;
|
---|
567 | rect.p1.y = 8;
|
---|
568 |
|
---|
569 | clip.p0.x = 1;
|
---|
570 | clip.p0.y = 2;
|
---|
571 | clip.p1.x = 5;
|
---|
572 | clip.p1.y = 6;
|
---|
573 |
|
---|
574 | gfx_rect_clip(&rect, &clip, &dest);
|
---|
575 | PCUT_ASSERT_INT_EQUALS(3, dest.p0.x);
|
---|
576 | PCUT_ASSERT_INT_EQUALS(4, dest.p0.y);
|
---|
577 | PCUT_ASSERT_INT_EQUALS(5, dest.p1.x);
|
---|
578 | PCUT_ASSERT_INT_EQUALS(6, dest.p1.y);
|
---|
579 | }
|
---|
580 |
|
---|
581 | /** Clip rectangle with no clipping rectangle */
|
---|
582 | PCUT_TEST(rect_clip_rect_noclip)
|
---|
583 | {
|
---|
584 | gfx_rect_t rect;
|
---|
585 | gfx_rect_t dest;
|
---|
586 |
|
---|
587 | rect.p0.x = 1;
|
---|
588 | rect.p0.y = 2;
|
---|
589 | rect.p1.x = 3;
|
---|
590 | rect.p1.y = 4;
|
---|
591 |
|
---|
592 | gfx_rect_clip(&rect, NULL, &dest);
|
---|
593 | PCUT_ASSERT_INT_EQUALS(rect.p0.x, dest.p0.x);
|
---|
594 | PCUT_ASSERT_INT_EQUALS(rect.p0.y, dest.p0.y);
|
---|
595 | PCUT_ASSERT_INT_EQUALS(rect.p1.x, dest.p1.x);
|
---|
596 | PCUT_ASSERT_INT_EQUALS(rect.p1.y, dest.p1.y);
|
---|
597 | }
|
---|
598 |
|
---|
599 | /** Center rectangle on rectangle */
|
---|
600 | PCUT_TEST(rect_ctr_on_rect)
|
---|
601 | {
|
---|
602 | gfx_rect_t a;
|
---|
603 | gfx_rect_t b;
|
---|
604 | gfx_rect_t dest;
|
---|
605 |
|
---|
606 | /* Dimensions: 20 x 20 */
|
---|
607 | b.p0.x = 10;
|
---|
608 | b.p0.y = 20;
|
---|
609 | b.p1.x = 30;
|
---|
610 | b.p1.y = 40;
|
---|
611 |
|
---|
612 | /* Dimensions: 20 x 20 */
|
---|
613 | a.p0.x = 100;
|
---|
614 | a.p0.y = 200;
|
---|
615 | a.p1.x = 120;
|
---|
616 | a.p1.y = 220;
|
---|
617 |
|
---|
618 | /* Centering rectangle of same size should give us the same rectangle */
|
---|
619 | gfx_rect_ctr_on_rect(&a, &b, &dest);
|
---|
620 | PCUT_ASSERT_INT_EQUALS(b.p0.x, dest.p0.x);
|
---|
621 | PCUT_ASSERT_INT_EQUALS(b.p0.y, dest.p0.y);
|
---|
622 | PCUT_ASSERT_INT_EQUALS(b.p1.x, dest.p1.x);
|
---|
623 | PCUT_ASSERT_INT_EQUALS(b.p1.y, dest.p1.y);
|
---|
624 |
|
---|
625 | /* Dimensions: 10 x 10 */
|
---|
626 | a.p0.x = 100;
|
---|
627 | a.p0.y = 200;
|
---|
628 | a.p1.x = 110;
|
---|
629 | a.p1.y = 210;
|
---|
630 |
|
---|
631 | gfx_rect_ctr_on_rect(&a, &b, &dest);
|
---|
632 | PCUT_ASSERT_INT_EQUALS(15, dest.p0.x);
|
---|
633 | PCUT_ASSERT_INT_EQUALS(25, dest.p0.y);
|
---|
634 | PCUT_ASSERT_INT_EQUALS(25, dest.p1.x);
|
---|
635 | PCUT_ASSERT_INT_EQUALS(35, dest.p1.y);
|
---|
636 | }
|
---|
637 |
|
---|
638 | /** Sort span points that are already sorted should produde indentical points */
|
---|
639 | PCUT_TEST(rect_points_sort_sorted)
|
---|
640 | {
|
---|
641 | gfx_coord_t s0, s1;
|
---|
642 |
|
---|
643 | gfx_span_points_sort(1, 2, &s0, &s1);
|
---|
644 | PCUT_ASSERT_INT_EQUALS(1, s0);
|
---|
645 | PCUT_ASSERT_INT_EQUALS(2, s1);
|
---|
646 | }
|
---|
647 |
|
---|
648 | /** Sort span points that are reversed should transpose them */
|
---|
649 | PCUT_TEST(rect_points_sort_reversed)
|
---|
650 | {
|
---|
651 | gfx_coord_t s0, s1;
|
---|
652 |
|
---|
653 | gfx_span_points_sort(2, 1, &s0, &s1);
|
---|
654 | PCUT_ASSERT_INT_EQUALS(2, s0);
|
---|
655 | PCUT_ASSERT_INT_EQUALS(3, s1);
|
---|
656 | }
|
---|
657 |
|
---|
658 | /** Rectangle dimensions for straight rectangle are computed correctly */
|
---|
659 | PCUT_TEST(rect_dims_straight)
|
---|
660 | {
|
---|
661 | gfx_rect_t rect;
|
---|
662 | gfx_coord2_t dims;
|
---|
663 |
|
---|
664 | rect.p0.x = 1;
|
---|
665 | rect.p0.y = 10;
|
---|
666 | rect.p1.x = 100;
|
---|
667 | rect.p1.y = 1000;
|
---|
668 |
|
---|
669 | gfx_rect_dims(&rect, &dims);
|
---|
670 |
|
---|
671 | PCUT_ASSERT_INT_EQUALS(99, dims.x);
|
---|
672 | PCUT_ASSERT_INT_EQUALS(990, dims.y);
|
---|
673 | }
|
---|
674 |
|
---|
675 | /** Rectangle dimensions for reversed rectangle are computed correctly */
|
---|
676 | PCUT_TEST(rect_dims_reversed)
|
---|
677 | {
|
---|
678 | gfx_rect_t rect;
|
---|
679 | gfx_coord2_t dims;
|
---|
680 |
|
---|
681 | rect.p0.x = 1000;
|
---|
682 | rect.p0.y = 100;
|
---|
683 | rect.p1.x = 10;
|
---|
684 | rect.p1.y = 1;
|
---|
685 |
|
---|
686 | gfx_rect_dims(&rect, &dims);
|
---|
687 |
|
---|
688 | PCUT_ASSERT_INT_EQUALS(990, dims.x);
|
---|
689 | PCUT_ASSERT_INT_EQUALS(99, dims.y);
|
---|
690 | }
|
---|
691 |
|
---|
692 | /** gfx_rect_is_empty for straight rectangle with zero columns returns true */
|
---|
693 | PCUT_TEST(rect_is_empty_pos_x)
|
---|
694 | {
|
---|
695 | gfx_rect_t rect;
|
---|
696 |
|
---|
697 | rect.p0.x = 1;
|
---|
698 | rect.p0.y = 2;
|
---|
699 | rect.p1.x = 1;
|
---|
700 | rect.p1.y = 3;
|
---|
701 | PCUT_ASSERT_TRUE(gfx_rect_is_empty(&rect));
|
---|
702 | }
|
---|
703 |
|
---|
704 | /** gfx_rect_is_empty for straight rectangle with zero rows returns true */
|
---|
705 | PCUT_TEST(rect_is_empty_pos_y)
|
---|
706 | {
|
---|
707 | gfx_rect_t rect;
|
---|
708 |
|
---|
709 | rect.p0.x = 1;
|
---|
710 | rect.p0.y = 2;
|
---|
711 | rect.p1.x = 2;
|
---|
712 | rect.p1.y = 2;
|
---|
713 | PCUT_ASSERT_TRUE(gfx_rect_is_empty(&rect));
|
---|
714 | }
|
---|
715 |
|
---|
716 | /** gfx_rect_is_empty for straight non-empty rectangle returns false */
|
---|
717 | PCUT_TEST(rect_is_empty_neg)
|
---|
718 | {
|
---|
719 | gfx_rect_t rect;
|
---|
720 |
|
---|
721 | rect.p0.x = 1;
|
---|
722 | rect.p0.y = 2;
|
---|
723 | rect.p1.x = 2;
|
---|
724 | rect.p1.y = 3;
|
---|
725 | PCUT_ASSERT_FALSE(gfx_rect_is_empty(&rect));
|
---|
726 | }
|
---|
727 |
|
---|
728 | /** gfx_rect_is_empty for reverse non-empty rectangle returns false */
|
---|
729 | PCUT_TEST(rect_is_empty_reverse_neg)
|
---|
730 | {
|
---|
731 | gfx_rect_t rect;
|
---|
732 |
|
---|
733 | rect.p0.x = 1;
|
---|
734 | rect.p0.y = 2;
|
---|
735 | rect.p1.x = 0;
|
---|
736 | rect.p1.y = 1;
|
---|
737 | PCUT_ASSERT_FALSE(gfx_rect_is_empty(&rect));
|
---|
738 | }
|
---|
739 |
|
---|
740 | /** gfx_rect_is_incident for neighboring rectangles returns false */
|
---|
741 | PCUT_TEST(rect_is_incident_neighbor)
|
---|
742 | {
|
---|
743 | gfx_rect_t a;
|
---|
744 | gfx_rect_t b;
|
---|
745 |
|
---|
746 | a.p0.x = 1;
|
---|
747 | a.p0.y = 2;
|
---|
748 | a.p1.x = 3;
|
---|
749 | a.p1.y = 4;
|
---|
750 |
|
---|
751 | b.p0.x = 3;
|
---|
752 | b.p0.y = 2;
|
---|
753 | b.p1.x = 5;
|
---|
754 | b.p1.y = 6;
|
---|
755 |
|
---|
756 | PCUT_ASSERT_FALSE(gfx_rect_is_incident(&a, &b));
|
---|
757 | }
|
---|
758 |
|
---|
759 | /** gfx_rect_is_incident for a inside b returns true */
|
---|
760 | PCUT_TEST(rect_is_incident_a_inside_b)
|
---|
761 | {
|
---|
762 | gfx_rect_t a;
|
---|
763 | gfx_rect_t b;
|
---|
764 |
|
---|
765 | a.p0.x = 2;
|
---|
766 | a.p0.y = 3;
|
---|
767 | a.p1.x = 4;
|
---|
768 | a.p1.y = 5;
|
---|
769 |
|
---|
770 | b.p0.x = 1;
|
---|
771 | b.p0.y = 2;
|
---|
772 | b.p1.x = 5;
|
---|
773 | b.p1.y = 6;
|
---|
774 |
|
---|
775 | PCUT_ASSERT_TRUE(gfx_rect_is_incident(&a, &b));
|
---|
776 | }
|
---|
777 |
|
---|
778 | /** gfx_rect_is_incident for b inside a returns true */
|
---|
779 | PCUT_TEST(rect_is_incident_b_inside_a)
|
---|
780 | {
|
---|
781 | gfx_rect_t a;
|
---|
782 | gfx_rect_t b;
|
---|
783 |
|
---|
784 | a.p0.x = 1;
|
---|
785 | a.p0.y = 2;
|
---|
786 | a.p1.x = 5;
|
---|
787 | a.p1.y = 6;
|
---|
788 |
|
---|
789 | b.p0.x = 2;
|
---|
790 | b.p0.y = 3;
|
---|
791 | b.p1.x = 4;
|
---|
792 | b.p1.y = 5;
|
---|
793 |
|
---|
794 | PCUT_ASSERT_TRUE(gfx_rect_is_incident(&a, &b));
|
---|
795 | }
|
---|
796 |
|
---|
797 | /** gfx_rect_is_incident for a and b sharing corner returns true */
|
---|
798 | PCUT_TEST(rect_is_incident_corner)
|
---|
799 | {
|
---|
800 | gfx_rect_t a;
|
---|
801 | gfx_rect_t b;
|
---|
802 |
|
---|
803 | a.p0.x = 1;
|
---|
804 | a.p0.y = 2;
|
---|
805 | a.p1.x = 3;
|
---|
806 | a.p1.y = 4;
|
---|
807 |
|
---|
808 | b.p0.x = 2;
|
---|
809 | b.p0.y = 3;
|
---|
810 | b.p1.x = 4;
|
---|
811 | b.p1.y = 5;
|
---|
812 |
|
---|
813 | PCUT_ASSERT_TRUE(gfx_rect_is_incident(&a, &b));
|
---|
814 | }
|
---|
815 |
|
---|
816 | /** gfx_rect_is_incident for a == b returns true */
|
---|
817 | PCUT_TEST(rect_is_incident_same)
|
---|
818 | {
|
---|
819 | gfx_rect_t a;
|
---|
820 | gfx_rect_t b;
|
---|
821 |
|
---|
822 | a.p0.x = 1;
|
---|
823 | a.p0.y = 2;
|
---|
824 | a.p1.x = 3;
|
---|
825 | a.p1.y = 4;
|
---|
826 |
|
---|
827 | b.p0.x = 1;
|
---|
828 | b.p0.y = 2;
|
---|
829 | b.p1.x = 3;
|
---|
830 | b.p1.y = 4;
|
---|
831 |
|
---|
832 | PCUT_ASSERT_TRUE(gfx_rect_is_incident(&a, &b));
|
---|
833 | }
|
---|
834 |
|
---|
835 | /** gfx_rect_is_inside is true for rectangle strictly inside */
|
---|
836 | PCUT_TEST(rect_is_inside_strict)
|
---|
837 | {
|
---|
838 | gfx_rect_t a;
|
---|
839 | gfx_rect_t b;
|
---|
840 |
|
---|
841 | a.p0.x = 2;
|
---|
842 | a.p0.y = 3;
|
---|
843 | a.p1.x = 4;
|
---|
844 | a.p1.y = 5;
|
---|
845 |
|
---|
846 | b.p0.x = 1;
|
---|
847 | b.p0.y = 2;
|
---|
848 | b.p1.x = 5;
|
---|
849 | b.p1.y = 6;
|
---|
850 |
|
---|
851 | PCUT_ASSERT_TRUE(gfx_rect_is_inside(&a, &b));
|
---|
852 | }
|
---|
853 |
|
---|
854 | /** gfx_rect_is_inside is true for two equal rectangles */
|
---|
855 | PCUT_TEST(rect_is_inside_same)
|
---|
856 | {
|
---|
857 | gfx_rect_t a;
|
---|
858 | gfx_rect_t b;
|
---|
859 |
|
---|
860 | a.p0.x = 1;
|
---|
861 | a.p0.y = 2;
|
---|
862 | a.p1.x = 3;
|
---|
863 | a.p1.y = 4;
|
---|
864 |
|
---|
865 | b.p0.x = 1;
|
---|
866 | b.p0.y = 2;
|
---|
867 | b.p1.x = 3;
|
---|
868 | b.p1.y = 4;
|
---|
869 |
|
---|
870 | PCUT_ASSERT_TRUE(gfx_rect_is_inside(&a, &b));
|
---|
871 | }
|
---|
872 |
|
---|
873 | /** gfx_rect_is_inside is false for @c a.p0 outside */
|
---|
874 | PCUT_TEST(rect_is_inside_p0_outside)
|
---|
875 | {
|
---|
876 | gfx_rect_t a;
|
---|
877 | gfx_rect_t b;
|
---|
878 |
|
---|
879 | a.p0.x = 0;
|
---|
880 | a.p0.y = 2;
|
---|
881 | a.p1.x = 3;
|
---|
882 | a.p1.y = 4;
|
---|
883 |
|
---|
884 | b.p0.x = 1;
|
---|
885 | b.p0.y = 2;
|
---|
886 | b.p1.x = 3;
|
---|
887 | b.p1.y = 4;
|
---|
888 |
|
---|
889 | PCUT_ASSERT_FALSE(gfx_rect_is_inside(&a, &b));
|
---|
890 |
|
---|
891 | a.p0.x = 1;
|
---|
892 | a.p0.y = 1;
|
---|
893 | a.p1.x = 3;
|
---|
894 | a.p1.y = 4;
|
---|
895 |
|
---|
896 | b.p0.x = 1;
|
---|
897 | b.p0.y = 2;
|
---|
898 | b.p1.x = 3;
|
---|
899 | b.p1.y = 4;
|
---|
900 |
|
---|
901 | PCUT_ASSERT_FALSE(gfx_rect_is_inside(&a, &b));
|
---|
902 | }
|
---|
903 |
|
---|
904 | /** gfx_rect_is_inside is false for @c a.p1 outside */
|
---|
905 | PCUT_TEST(rect_is_inside_p1_outside)
|
---|
906 | {
|
---|
907 | gfx_rect_t a;
|
---|
908 | gfx_rect_t b;
|
---|
909 |
|
---|
910 | a.p0.x = 1;
|
---|
911 | a.p0.y = 2;
|
---|
912 | a.p1.x = 4;
|
---|
913 | a.p1.y = 4;
|
---|
914 |
|
---|
915 | b.p0.x = 1;
|
---|
916 | b.p0.y = 2;
|
---|
917 | b.p1.x = 3;
|
---|
918 | b.p1.y = 4;
|
---|
919 |
|
---|
920 | PCUT_ASSERT_FALSE(gfx_rect_is_inside(&a, &b));
|
---|
921 |
|
---|
922 | a.p0.x = 1;
|
---|
923 | a.p0.y = 2;
|
---|
924 | a.p1.x = 3;
|
---|
925 | a.p1.y = 5;
|
---|
926 |
|
---|
927 | b.p0.x = 1;
|
---|
928 | b.p0.y = 2;
|
---|
929 | b.p1.x = 3;
|
---|
930 | b.p1.y = 4;
|
---|
931 |
|
---|
932 | PCUT_ASSERT_FALSE(gfx_rect_is_inside(&a, &b));
|
---|
933 | }
|
---|
934 |
|
---|
935 | /** gfx_pix_inside_rect for */
|
---|
936 | PCUT_TEST(pix_inside_rect)
|
---|
937 | {
|
---|
938 | gfx_coord2_t coord;
|
---|
939 | gfx_rect_t rect;
|
---|
940 |
|
---|
941 | rect.p0.x = 1;
|
---|
942 | rect.p0.y = 2;
|
---|
943 | rect.p1.x = 3;
|
---|
944 | rect.p1.y = 4;
|
---|
945 |
|
---|
946 | coord.x = 0;
|
---|
947 | coord.y = 1;
|
---|
948 | PCUT_ASSERT_FALSE(gfx_pix_inside_rect(&coord, &rect));
|
---|
949 |
|
---|
950 | coord.x = 1;
|
---|
951 | coord.y = 1;
|
---|
952 | PCUT_ASSERT_FALSE(gfx_pix_inside_rect(&coord, &rect));
|
---|
953 |
|
---|
954 | coord.x = 0;
|
---|
955 | coord.y = 2;
|
---|
956 | PCUT_ASSERT_FALSE(gfx_pix_inside_rect(&coord, &rect));
|
---|
957 |
|
---|
958 | coord.x = 1;
|
---|
959 | coord.y = 2;
|
---|
960 | PCUT_ASSERT_TRUE(gfx_pix_inside_rect(&coord, &rect));
|
---|
961 |
|
---|
962 | coord.x = 2;
|
---|
963 | coord.y = 3;
|
---|
964 | PCUT_ASSERT_TRUE(gfx_pix_inside_rect(&coord, &rect));
|
---|
965 |
|
---|
966 | coord.x = 3;
|
---|
967 | coord.y = 3;
|
---|
968 | PCUT_ASSERT_FALSE(gfx_pix_inside_rect(&coord, &rect));
|
---|
969 |
|
---|
970 | coord.x = 2;
|
---|
971 | coord.y = 4;
|
---|
972 | PCUT_ASSERT_FALSE(gfx_pix_inside_rect(&coord, &rect));
|
---|
973 |
|
---|
974 | coord.x = 3;
|
---|
975 | coord.y = 4;
|
---|
976 | PCUT_ASSERT_FALSE(gfx_pix_inside_rect(&coord, &rect));
|
---|
977 | }
|
---|
978 |
|
---|
979 | PCUT_EXPORT(coord);
|
---|