[check] Filter programlistings for check-doc-syntax.sh
[cairo/haiku.git] / test / rel-path.c
blob0f42321b94fd6a473d7d6d8046353db9009e9df3
1 /*
2 * Copyright © 2005 Keith Packard
4 * Permission to use, copy, modify, distribute, and sell this software and its
5 * documentation for any purpose is hereby granted without fee, provided that
6 * the above copyright notice appear in all copies and that both that
7 * copyright notice and this permission notice appear in supporting
8 * documentation, and that the name of Keith Packard not be used in
9 * advertising or publicity pertaining to distribution of the software without
10 * specific, written prior permission. Keith Packard makes no
11 * representations about the suitability of this software for any purpose. It
12 * is provided "as is" without express or implied warranty.
14 * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
15 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
16 * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
17 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
18 * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
19 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
20 * PERFORMANCE OF THIS SOFTWARE.
23 #include "cairo-test.h"
25 #define SIZE 10
27 static cairo_test_draw_function_t draw;
29 cairo_test_t test = {
30 "rel-path",
31 "Tests calls to various relative path functions",
32 SIZE, SIZE,
33 draw
36 static cairo_status_t
37 invalid_rel_move_to (cairo_surface_t *target)
39 cairo_t *cr;
40 cairo_status_t status;
42 cr = cairo_create (target);
43 cairo_rel_move_to (cr, SIZE, SIZE/2);
44 status = cairo_status (cr);
45 cairo_destroy (cr);
47 return status;
50 static cairo_status_t
51 invalid_rel_line_to (cairo_surface_t *target)
53 cairo_t *cr;
54 cairo_status_t status;
56 cr = cairo_create (target);
57 cairo_rel_line_to (cr, -SIZE, SIZE/2);
58 status = cairo_status (cr);
59 cairo_destroy (cr);
61 return status;
64 static cairo_status_t
65 invalid_rel_curve_to (cairo_surface_t *target)
67 cairo_t *cr;
68 cairo_status_t status;
70 cr = cairo_create (target);
71 cairo_rel_curve_to (cr,
72 SIZE/2, -SIZE/2,
73 SIZE*2/3, -SIZE/3,
74 SIZE/2, -SIZE);
75 status = cairo_status (cr);
76 cairo_destroy (cr);
78 return status;
81 static cairo_test_status_t
82 draw (cairo_t *cr, int width, int height)
84 cairo_status_t status;
86 /* first test that a relative move without a current point fails... */
87 status = invalid_rel_move_to (cairo_get_target (cr));
88 if (status != CAIRO_STATUS_NO_CURRENT_POINT) {
89 cairo_test_log ("Error: invalid cairo_rel_move_to() did not raise NO_CURRENT_POINT\n");
90 return CAIRO_TEST_FAILURE;
93 status = invalid_rel_line_to (cairo_get_target (cr));
94 if (status != CAIRO_STATUS_NO_CURRENT_POINT) {
95 cairo_test_log ("Error: invalid cairo_rel_line_to() did not raise NO_CURRENT_POINT\n");
96 return CAIRO_TEST_FAILURE;
99 status = invalid_rel_curve_to (cairo_get_target (cr));
100 if (status != CAIRO_STATUS_NO_CURRENT_POINT) {
101 cairo_test_log ("Error: invalid cairo_rel_curve_to() did not raise NO_CURRENT_POINT\n");
102 return CAIRO_TEST_FAILURE;
105 cairo_set_source_rgb (cr, 1, 1, 1);
106 cairo_move_to (cr, 0, 0);
107 cairo_rel_move_to (cr, SIZE, SIZE/2);
108 cairo_rel_line_to (cr, -SIZE, SIZE/2);
109 cairo_rel_curve_to (cr,
110 SIZE/2, -SIZE/2,
111 SIZE*2/3, -SIZE/3,
112 SIZE/2, -SIZE);
114 cairo_stroke (cr);
116 return CAIRO_TEST_SUCCESS;
120 main (void)
122 return cairo_test (&test);