diff options
author | Chris Wilson <chris@chris-wilson.co.uk> | 2009-03-17 11:58:16 +0000 |
---|---|---|
committer | Chris Wilson <chris@chris-wilson.co.uk> | 2009-03-18 09:44:33 +0000 |
commit | 7db55b37d4aef188e04771b45076f6735507c209 (patch) | |
tree | d9f879786318250fc431012608729c37d9ce4ff1 | |
parent | dc176d88ac03ae71fc32abb27329a35650801d99 (diff) |
[test] Destroy pattern on error paths.
Destroy the pattern after encountering an error in pattern-getters test.
-rw-r--r-- | test/pattern-getters.c | 29 |
1 files changed, 25 insertions, 4 deletions
diff --git a/test/pattern-getters.c b/test/pattern-getters.c index 0b9c86b1..657159c2 100644 --- a/test/pattern-getters.c +++ b/test/pattern-getters.c @@ -27,7 +27,12 @@ #include <stdlib.h> #include "cairo-test.h" -#define CHECK_SUCCESS do { if (status) return CAIRO_TEST_FAILURE; } while (0) +#define CHECK_SUCCESS do { \ + if (status) { \ + cairo_pattern_destroy (pat); \ + return cairo_test_status_from_status (ctx, status); \ + } \ +} while (0) static int double_buf_equal (const cairo_test_context_t *ctx, double *a, double *b, int nc) @@ -64,6 +69,7 @@ draw (cairo_t *cr, int width, int height) !CAIRO_TEST_DOUBLE_EQUALS(a,0.5)) { cairo_test_log (ctx, "Error: cairo_pattern_get_rgba returned unexepcted results: %g, %g, %g, %g\n", r, g, b, a); + cairo_pattern_destroy (pat); return CAIRO_TEST_FAILURE; } @@ -81,6 +87,7 @@ draw (cairo_t *cr, int width, int height) if (surf != cairo_get_target (cr)) { cairo_test_log (ctx, "Error: cairo_pattern_get_resurface returned wrong surface\n"); + cairo_pattern_destroy (pat); return CAIRO_TEST_FAILURE; } @@ -114,13 +121,18 @@ draw (cairo_t *cr, int width, int height) !CAIRO_TEST_DOUBLE_EQUALS(y0,2.0) || !CAIRO_TEST_DOUBLE_EQUALS(x1,3.0) || !CAIRO_TEST_DOUBLE_EQUALS(y1,4.0)) + { + cairo_pattern_destroy (pat); return CAIRO_TEST_FAILURE; + } status = cairo_pattern_get_color_stop_count (pat, &i); CHECK_SUCCESS; - if (i != 3) + if (i != 3) { + cairo_pattern_destroy (pat); return CAIRO_TEST_FAILURE; + } for (i = 0; i < 3; i++) { status = cairo_pattern_get_color_stop_rgba (pat, i, @@ -133,11 +145,17 @@ draw (cairo_t *cr, int width, int height) } status = cairo_pattern_get_color_stop_rgba (pat, 5, NULL, NULL, NULL, NULL, NULL); - if (status != CAIRO_STATUS_INVALID_INDEX) + if (status != CAIRO_STATUS_INVALID_INDEX) { + cairo_pattern_destroy (pat); return CAIRO_TEST_FAILURE; + } - if (!double_buf_equal (ctx, new_buf, expected_values, sizeof(expected_values)/sizeof(double)) != 0) + if (!double_buf_equal (ctx, new_buf, expected_values, + sizeof(expected_values)/sizeof(double)) != 0) + { + cairo_pattern_destroy (pat); return CAIRO_TEST_FAILURE; + } cairo_pattern_destroy (pat); } @@ -157,7 +175,10 @@ draw (cairo_t *cr, int width, int height) !CAIRO_TEST_DOUBLE_EQUALS(d,4.0) || !CAIRO_TEST_DOUBLE_EQUALS(e,5.0) || !CAIRO_TEST_DOUBLE_EQUALS(f,6.0)) + { + cairo_pattern_destroy (pat); return CAIRO_TEST_FAILURE; + } cairo_pattern_destroy (pat); } |