diff options
author | Chris Wilson <chris@chris-wilson.co.uk> | 2008-01-12 10:49:48 +0000 |
---|---|---|
committer | Chris Wilson <chris@chris-wilson.co.uk> | 2008-01-12 10:49:48 +0000 |
commit | ac98c9e572135f5f46303ce49e6a04f86efe2676 (patch) | |
tree | 152631144361bcd45900451518878e6e378d9442 /test/rel-path.c | |
parent | 6cc75cfe5b962566938189b5a7dd63135e981300 (diff) | |
download | cairo-ac98c9e572135f5f46303ce49e6a04f86efe2676.tar.gz |
[test/rel-path] Check that invalid relative paths raise an error.
Check that NO_CURRENT_PATH is raised if a relative path op is used
on a new path.
Diffstat (limited to 'test/rel-path.c')
-rw-r--r-- | test/rel-path.c | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/test/rel-path.c b/test/rel-path.c index 1da3557a2..0f42321b9 100644 --- a/test/rel-path.c +++ b/test/rel-path.c @@ -33,9 +33,75 @@ cairo_test_t test = { draw }; +static cairo_status_t +invalid_rel_move_to (cairo_surface_t *target) +{ + cairo_t *cr; + cairo_status_t status; + + cr = cairo_create (target); + cairo_rel_move_to (cr, SIZE, SIZE/2); + status = cairo_status (cr); + cairo_destroy (cr); + + return status; +} + +static cairo_status_t +invalid_rel_line_to (cairo_surface_t *target) +{ + cairo_t *cr; + cairo_status_t status; + + cr = cairo_create (target); + cairo_rel_line_to (cr, -SIZE, SIZE/2); + status = cairo_status (cr); + cairo_destroy (cr); + + return status; +} + +static cairo_status_t +invalid_rel_curve_to (cairo_surface_t *target) +{ + cairo_t *cr; + cairo_status_t status; + + cr = cairo_create (target); + cairo_rel_curve_to (cr, + SIZE/2, -SIZE/2, + SIZE*2/3, -SIZE/3, + SIZE/2, -SIZE); + status = cairo_status (cr); + cairo_destroy (cr); + + return status; +} + static cairo_test_status_t draw (cairo_t *cr, int width, int height) { + cairo_status_t status; + + /* first test that a relative move without a current point fails... */ + status = invalid_rel_move_to (cairo_get_target (cr)); + if (status != CAIRO_STATUS_NO_CURRENT_POINT) { + cairo_test_log ("Error: invalid cairo_rel_move_to() did not raise NO_CURRENT_POINT\n"); + return CAIRO_TEST_FAILURE; + } + + status = invalid_rel_line_to (cairo_get_target (cr)); + if (status != CAIRO_STATUS_NO_CURRENT_POINT) { + cairo_test_log ("Error: invalid cairo_rel_line_to() did not raise NO_CURRENT_POINT\n"); + return CAIRO_TEST_FAILURE; + } + + status = invalid_rel_curve_to (cairo_get_target (cr)); + if (status != CAIRO_STATUS_NO_CURRENT_POINT) { + cairo_test_log ("Error: invalid cairo_rel_curve_to() did not raise NO_CURRENT_POINT\n"); + return CAIRO_TEST_FAILURE; + } + cairo_set_source_rgb (cr, 1, 1, 1); cairo_move_to (cr, 0, 0); cairo_rel_move_to (cr, SIZE, SIZE/2); |