summaryrefslogtreecommitdiff
path: root/test/png.c
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2010-05-03 19:21:59 +0100
committerChris Wilson <chris@chris-wilson.co.uk>2010-05-03 19:21:59 +0100
commitaf26560f258d93cc78782ddd0208128756874c11 (patch)
tree43c77d3b21b57cd7143a04ec73c30a8b60dc73df /test/png.c
parentc549203c8d69474be4362037f702e4fb59c9929e (diff)
downloadcairo-af26560f258d93cc78782ddd0208128756874c11.tar.gz
test: Improve memfault behaviour.
Various minor tweaks to convert asserts into error returns and to improve error checking on intermediate surfaces.
Diffstat (limited to 'test/png.c')
-rw-r--r--test/png.c34
1 files changed, 23 insertions, 11 deletions
diff --git a/test/png.c b/test/png.c
index 9f082c9dc..e90ac668b 100644
--- a/test/png.c
+++ b/test/png.c
@@ -55,6 +55,7 @@ format_to_string (cairo_format_t format)
switch (format) {
case CAIRO_FORMAT_A1: return "a1";
case CAIRO_FORMAT_A8: return "a8";
+ case CAIRO_FORMAT_RGB16_565: return "rgb16";
case CAIRO_FORMAT_RGB24: return "rgb24";
case CAIRO_FORMAT_ARGB32: return "argb32";
case CAIRO_FORMAT_INVALID:
@@ -79,61 +80,72 @@ preamble (cairo_test_context_t *ctx)
cairo_surface_t *surface0, *surface1;
cairo_status_t status;
uint32_t argb32 = 0xdeadbede;
- cairo_test_status_t result = CAIRO_TEST_SUCCESS;
surface0 = cairo_image_surface_create_for_data ((unsigned char *) &argb32,
CAIRO_FORMAT_ARGB32,
1, 1, 4);
- assert (cairo_surface_status (surface0) == CAIRO_STATUS_SUCCESS);
status = cairo_surface_write_to_png (surface0, filename);
if (status) {
cairo_test_log (ctx, "Error writing '%s': %s\n",
filename, cairo_status_to_string (status));
- result = CAIRO_TEST_FAILURE;
+
+ cairo_surface_destroy (surface0);
+ return cairo_test_status_from_status (ctx, status);
}
surface1 = cairo_image_surface_create_from_png (filename);
status = cairo_surface_status (surface1);
if (status) {
cairo_test_log (ctx, "Error reading '%s': %s\n",
filename, cairo_status_to_string (status));
- result = CAIRO_TEST_FAILURE;
+
+ cairo_surface_destroy (surface1);
+ cairo_surface_destroy (surface0);
+ return cairo_test_status_from_status (ctx, status);
}
if (! image_surface_equals (surface0, surface1)) {
cairo_test_log (ctx, "Error surface mismatch.\n");
cairo_test_log (ctx, "to png: "); print_surface (ctx, surface0);
cairo_test_log (ctx, "from png: "); print_surface (ctx, surface1);
- result = CAIRO_TEST_FAILURE;
+
+ cairo_surface_destroy (surface0);
+ cairo_surface_destroy (surface1);
+ return CAIRO_TEST_FAILURE;
}
assert (*(uint32_t *) cairo_image_surface_get_data (surface1) == argb32);
cairo_surface_destroy (surface0);
cairo_surface_destroy (surface1);
-
surface0 = cairo_image_surface_create_for_data ((unsigned char *) &argb32,
CAIRO_FORMAT_RGB24,
1, 1, 4);
- assert (cairo_surface_status (surface0) == CAIRO_STATUS_SUCCESS);
status = cairo_surface_write_to_png (surface0, filename);
if (status) {
cairo_test_log (ctx, "Error writing '%s': %s\n",
filename, cairo_status_to_string (status));
- result = CAIRO_TEST_FAILURE;
+ cairo_surface_destroy (surface0);
+ return cairo_test_status_from_status (ctx, status);
}
surface1 = cairo_image_surface_create_from_png (filename);
status = cairo_surface_status (surface1);
if (status) {
cairo_test_log (ctx, "Error reading '%s': %s\n",
filename, cairo_status_to_string (status));
- result = CAIRO_TEST_FAILURE;
+
+ cairo_surface_destroy (surface1);
+ cairo_surface_destroy (surface0);
+ return cairo_test_status_from_status (ctx, status);
}
if (! image_surface_equals (surface0, surface1)) {
cairo_test_log (ctx, "Error surface mismatch.\n");
cairo_test_log (ctx, "to png: "); print_surface (ctx, surface0);
cairo_test_log (ctx, "from png: "); print_surface (ctx, surface1);
- result = CAIRO_TEST_FAILURE;
+
+ cairo_surface_destroy (surface0);
+ cairo_surface_destroy (surface1);
+ return CAIRO_TEST_FAILURE;
}
assert ((*(uint32_t *) cairo_image_surface_get_data (surface1) & RGB_MASK)
== (argb32 & RGB_MASK));
@@ -141,7 +153,7 @@ preamble (cairo_test_context_t *ctx)
cairo_surface_destroy (surface0);
cairo_surface_destroy (surface1);
- return result;
+ return CAIRO_TEST_SUCCESS;
}
CAIRO_TEST (png,