summaryrefslogtreecommitdiff
path: root/test/cairo_test.c
diff options
context:
space:
mode:
authorCarl Worth <cworth@cworth.org>2005-03-09 14:34:26 +0000
committerCarl Worth <cworth@cworth.org>2005-03-09 14:34:26 +0000
commit0daf6b1745fa6a64652849f280da42781aeb296b (patch)
treecc6fdd927784f017e3a7556fe391afcdebf71912 /test/cairo_test.c
parentc3bd9b1b8d55d1128a7f70096b7135a80c6c9bed (diff)
Move filename initialization up to before first use.
Add test for the most trivial cairo_get and cairo_set functions.
Diffstat (limited to 'test/cairo_test.c')
-rw-r--r--test/cairo_test.c22
1 files changed, 12 insertions, 10 deletions
diff --git a/test/cairo_test.c b/test/cairo_test.c
index b3b3251c4..0c3ae8fe9 100644
--- a/test/cairo_test.c
+++ b/test/cairo_test.c
@@ -113,7 +113,16 @@ cairo_test (cairo_test_t *test, cairo_test_draw_function_t draw)
xunlink (log_name);
- /* The cairo part of the test is the easiest part */
+ /* Get the strings ready that we'll need. */
+ srcdir = getenv ("srcdir");
+ if (!srcdir)
+ srcdir = ".";
+ xasprintf (&log_name, "%s%s", test->name, CAIRO_TEST_LOG_SUFFIX);
+ xasprintf (&png_name, "%s%s", test->name, CAIRO_TEST_PNG_SUFFIX);
+ xasprintf (&ref_name, "%s/%s%s", srcdir, test->name, CAIRO_TEST_REF_SUFFIX);
+ xasprintf (&diff_name, "%s%s", test->name, CAIRO_TEST_DIFF_SUFFIX);
+
+ /* Run the actual drawing code. */
cr = cairo_create ();
stride = 4 * test->width;
@@ -125,6 +134,8 @@ cairo_test (cairo_test_t *test, cairo_test_draw_function_t draw)
test->width, test->height, stride);
status = (draw) (cr, test->width, test->height);
+
+ /* Then, check all the different ways it could fail. */
if (status) {
log_file = fopen (log_name, "a");
fprintf (log_file, "Error: Function under test failed\n");
@@ -148,15 +159,6 @@ cairo_test (cairo_test_t *test, cairo_test_draw_function_t draw)
return CAIRO_TEST_SUCCESS;
}
- /* Then we've got a bunch of string manipulation and file I/O for the check */
- srcdir = getenv ("srcdir");
- if (!srcdir)
- srcdir = ".";
- xasprintf (&log_name, "%s%s", test->name, CAIRO_TEST_LOG_SUFFIX);
- xasprintf (&png_name, "%s%s", test->name, CAIRO_TEST_PNG_SUFFIX);
- xasprintf (&ref_name, "%s/%s%s", srcdir, test->name, CAIRO_TEST_REF_SUFFIX);
- xasprintf (&diff_name, "%s%s", test->name, CAIRO_TEST_DIFF_SUFFIX);
-
png_file = fopen (png_name, "w");
write_png_argb32 (png_buf, png_file, test->width, test->height, stride);
fclose (png_file);