[check] Filter programlistings for check-doc-syntax.sh
[cairo/haiku.git] / test / in-fill-trapezoid.c
bloba544e43927e611d99ef73bf9221744775da68862
1 /*
2 * Copyright © 2008 Chris Wilson
4 * Permission is hereby granted, free of charge, to any person
5 * obtaining a copy of this software and associated documentation
6 * files (the "Software"), to deal in the Software without
7 * restriction, including without limitation the rights to use, copy,
8 * modify, merge, publish, distribute, sublicense, and/or sell copies
9 * of the Software, and to permit persons to whom the Software is
10 * furnished to do so, subject to the following conditions:
12 * The above copyright notice and this permission notice shall be
13 * included in all copies or substantial portions of the Software.
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
19 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
20 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 * SOFTWARE.
24 * Author: Chris Wilson <chris@chris-wilson.co.uk>
27 #include "cairo-test.h"
29 static cairo_test_draw_function_t draw;
31 cairo_test_t test = {
32 "in-fill-trapezoid",
33 "Test _cairo_trap_contains via cairo_in_fill",
34 0, 0,
35 draw
38 static cairo_test_status_t
39 draw (cairo_t *cr, int width, int height)
41 cairo_test_status_t ret = CAIRO_TEST_SUCCESS;
43 cairo_set_fill_rule (cr, CAIRO_FILL_RULE_EVEN_ODD);
45 /* simple rectangle */
46 cairo_new_path (cr);
47 cairo_rectangle (cr, -10, -10, 20, 20);
48 if (! cairo_in_fill (cr, 0, 0)) {
49 cairo_test_log ("Error: Failed to find point inside rectangle\n");
50 ret = CAIRO_TEST_FAILURE;
53 /* simple circle */
54 cairo_new_path (cr);
55 cairo_arc (cr, 0, 0, 10, 0, 2 * M_PI);
56 if (! cairo_in_fill (cr, 0, 0)) {
57 cairo_test_log ("Error: Failed to find point inside circle\n");
58 ret = CAIRO_TEST_FAILURE;
61 /* holey rectangle */
62 cairo_new_path (cr);
63 cairo_rectangle (cr, -10, -10, 20, 20);
64 cairo_rectangle (cr, -5, -5, 10, 10);
65 if (cairo_in_fill (cr, 0, 0)) {
66 cairo_test_log ("Error: Found an unexpected point inside rectangular hole\n");
67 ret = CAIRO_TEST_FAILURE;
70 /* holey circle */
71 cairo_new_path (cr);
72 cairo_arc (cr, 0, 0, 10, 0, 2 * M_PI);
73 cairo_arc (cr, 0, 0, 5, 0, 2 * M_PI);
74 if (cairo_in_fill (cr, 0, 0)) {
75 cairo_test_log ("Error: Found an unexpected point inside circular hole\n");
76 ret = CAIRO_TEST_FAILURE;
79 return ret;
82 int
83 main (void)
85 return cairo_test (&test);