diff options
author | Behdad Esfahbod <behdad@behdad.org> | 2008-02-25 19:48:58 -0500 |
---|---|---|
committer | Behdad Esfahbod <behdad@behdad.org> | 2008-02-25 19:48:58 -0500 |
commit | ecb54b96967ae0d1b5ec3a4d0955f46dd68f2b8b (patch) | |
tree | 2349ed62cf93207a44e5bda0575b60e462a6a422 /test | |
parent | be316b7cfae90878d05869329c85c9617019bbec (diff) |
[test/get-path-extents] Don't use short-circuit && operators
That causes some tests to be skipped if the preceding test failed.
Diffstat (limited to 'test')
-rw-r--r-- | test/get-path-extents.c | 143 |
1 files changed, 62 insertions, 81 deletions
diff --git a/test/get-path-extents.c b/test/get-path-extents.c index 6f3bc107..214596eb 100644 --- a/test/get-path-extents.c +++ b/test/get-path-extents.c @@ -108,7 +108,7 @@ draw (cairo_t *cr, int width, int height) const char *phase; const char string[] = "The quick brown fox jumps over the lazy dog."; cairo_text_extents_t extents, scaled_font_extents; - cairo_test_status_t ret = CAIRO_TEST_SUCCESS; + int errors = 0; surface = cairo_surface_create_similar (cairo_get_group_target (cr), CAIRO_CONTENT_COLOR, 100, 100); @@ -122,10 +122,9 @@ draw (cairo_t *cr, int width, int height) cairo_set_miter_limit (cr2, 100); phase = "No path"; - if (!check_extents (phase, cr2, FILL, EQUALS, 0, 0, 0, 0) || - !check_extents (phase, cr2, STROKE, EQUALS, 0, 0, 0, 0) || - !check_extents (phase, cr2, PATH, EQUALS, 0, 0, 0, 0)) - ret = CAIRO_TEST_FAILURE; + errors += !check_extents (phase, cr2, FILL, EQUALS, 0, 0, 0, 0); + errors += !check_extents (phase, cr2, STROKE, EQUALS, 0, 0, 0, 0); + errors += !check_extents (phase, cr2, PATH, EQUALS, 0, 0, 0, 0); cairo_save (cr2); @@ -133,35 +132,31 @@ draw (cairo_t *cr, int width, int height) cairo_move_to (cr2, 200, 400); cairo_rel_line_to (cr2, 0., 0.); phase = "Degenerate line"; - if (!check_extents (phase, cr2, FILL, EQUALS, 0, 0, 0, 0) || - !check_extents (phase, cr2, STROKE, EQUALS, 0, 0, 0, 0) || - !check_extents (phase, cr2, PATH, EQUALS, 200, 400, 0, 0)) - ret = CAIRO_TEST_FAILURE; + errors += !check_extents (phase, cr2, FILL, EQUALS, 0, 0, 0, 0); + errors += !check_extents (phase, cr2, STROKE, EQUALS, 0, 0, 0, 0); + errors += !check_extents (phase, cr2, PATH, EQUALS, 200, 400, 0, 0); cairo_new_path (cr2); cairo_move_to (cr2, 200, 400); cairo_rel_curve_to (cr2, 0., 0., 0., 0., 0., 0.); phase = "Degenerate curve"; - if (!check_extents (phase, cr2, FILL, EQUALS, 0, 0, 0, 0) || - !check_extents (phase, cr2, STROKE, EQUALS, 0, 0, 0, 0) || - !check_extents (phase, cr2, PATH, EQUALS, 200, 400, 0, 0)) - ret = CAIRO_TEST_FAILURE; + errors += !check_extents (phase, cr2, FILL, EQUALS, 0, 0, 0, 0); + errors += !check_extents (phase, cr2, STROKE, EQUALS, 0, 0, 0, 0); + errors += !check_extents (phase, cr2, PATH, EQUALS, 200, 400, 0, 0); cairo_new_path (cr2); cairo_arc (cr2, 200, 400, 0., 0, 2 * M_PI); phase = "Degenerate arc (R=0)"; - if (!check_extents (phase, cr2, FILL, EQUALS, 0, 0, 0, 0) || - !check_extents (phase, cr2, STROKE, EQUALS, 0, 0, 0, 0) || - !check_extents (phase, cr2, PATH, EQUALS, 200, 400, 0, 0)) - ret = CAIRO_TEST_FAILURE; + errors += !check_extents (phase, cr2, FILL, EQUALS, 0, 0, 0, 0); + errors += !check_extents (phase, cr2, STROKE, EQUALS, 0, 0, 0, 0); + errors += !check_extents (phase, cr2, PATH, EQUALS, 200, 400, 0, 0); cairo_new_path (cr2); cairo_arc (cr2, 200, 400, 10., 0, 0); phase = "Degenerate arc (Θ=0)"; - if (!check_extents (phase, cr2, FILL, EQUALS, 0, 0, 0, 0) || - !check_extents (phase, cr2, STROKE, EQUALS, 0, 0, 0, 0) || - !check_extents (phase, cr2, PATH, EQUALS, 200, 400, 0, 0)) - ret = CAIRO_TEST_FAILURE; + errors += !check_extents (phase, cr2, FILL, EQUALS, 0, 0, 0, 0); + errors += !check_extents (phase, cr2, STROKE, EQUALS, 0, 0, 0, 0); + errors += !check_extents (phase, cr2, PATH, EQUALS, 200, 400, 0, 0); cairo_new_path (cr2); cairo_restore (cr2); @@ -176,19 +171,17 @@ draw (cairo_t *cr, int width, int height) cairo_move_to (cr2, 200, 400); cairo_rel_line_to (cr2, 0, 0); phase = "Single 'dot'"; - if (!check_extents (phase, cr2, FILL, EQUALS, 0, 0, 0, 0) || - !check_extents (phase, cr2, STROKE, EQUALS, 190, 390, 20, 20) || - !check_extents (phase, cr2, PATH, EQUALS, 200, 400, 0, 0)) - ret = CAIRO_TEST_FAILURE; + errors += !check_extents (phase, cr2, FILL, EQUALS, 0, 0, 0, 0); + errors += !check_extents (phase, cr2, STROKE, EQUALS, 190, 390, 20, 20); + errors += !check_extents (phase, cr2, PATH, EQUALS, 200, 400, 0, 0); /* Add another dot without starting a new path */ cairo_move_to (cr2, 100, 500); cairo_rel_line_to (cr2, 0, 0); phase = "Multiple 'dots'"; - if (!check_extents (phase, cr2, FILL, EQUALS, 0, 0, 0, 0) || - !check_extents (phase, cr2, STROKE, EQUALS, 90, 390, 120, 120) || - !check_extents (phase, cr2, PATH, EQUALS, 100, 400, 100, 100)) - ret = CAIRO_TEST_FAILURE; + errors += !check_extents (phase, cr2, FILL, EQUALS, 0, 0, 0, 0); + errors += !check_extents (phase, cr2, STROKE, EQUALS, 90, 390, 120, 120); + errors += !check_extents (phase, cr2, PATH, EQUALS, 100, 400, 100, 100); cairo_new_path (cr2); @@ -201,20 +194,18 @@ draw (cairo_t *cr, int width, int height) cairo_set_line_join (cr2, CAIRO_LINE_JOIN_ROUND); cairo_move_to (cr2, 0, 180); cairo_line_to (cr2, 750, 180); - if (!check_extents (phase, cr2, FILL, EQUALS, 0, 0, 0, 0) || - !check_extents (phase, cr2, STROKE, EQUALS, -5, 175, 760, 10) || - !check_extents (phase, cr2, PATH, EQUALS, 0, 180, 755, 0)) - ret = CAIRO_TEST_FAILURE; + errors += !check_extents (phase, cr2, FILL, EQUALS, 0, 0, 0, 0); + errors += !check_extents (phase, cr2, STROKE, EQUALS, -5, 175, 760, 10); + errors += !check_extents (phase, cr2, PATH, EQUALS, 0, 180, 755, 0); cairo_new_path (cr2); cairo_restore (cr2); phase = "Simple rect"; cairo_save (cr2); cairo_rectangle (cr2, 10, 10, 80, 80); - if (!check_extents (phase, cr2, FILL, EQUALS, 10, 10, 80, 80) || - !check_extents (phase, cr2, STROKE, EQUALS, 5, 5, 90, 90) || - !check_extents (phase, cr2, PATH, EQUALS, 10, 10, 80, 80)) - ret = CAIRO_TEST_FAILURE; + errors += !check_extents (phase, cr2, FILL, EQUALS, 10, 10, 80, 80); + errors += !check_extents (phase, cr2, STROKE, EQUALS, 5, 5, 90, 90); + errors += !check_extents (phase, cr2, PATH, EQUALS, 10, 10, 80, 80); cairo_new_path (cr2); cairo_restore (cr2); @@ -222,10 +213,9 @@ draw (cairo_t *cr, int width, int height) cairo_save (cr2); cairo_rectangle (cr2, 10, 10, 10, 10); cairo_rectangle (cr2, 20, 20, 10, 10); - if (!check_extents (phase, cr2, FILL, EQUALS, 10, 10, 20, 20) || - !check_extents (phase, cr2, STROKE, EQUALS, 5, 5, 30, 30) || - !check_extents (phase, cr2, PATH, EQUALS, 10, 10, 20, 20)) - ret = CAIRO_TEST_FAILURE; + errors += !check_extents (phase, cr2, FILL, EQUALS, 10, 10, 20, 20); + errors += !check_extents (phase, cr2, STROKE, EQUALS, 5, 5, 30, 30); + errors += !check_extents (phase, cr2, PATH, EQUALS, 10, 10, 20, 20); cairo_new_path (cr2); cairo_restore (cr2); @@ -237,10 +227,9 @@ draw (cairo_t *cr, int width, int height) cairo_close_path (cr2); /* miter joins protrude 5*(1+sqrt(2)) above the top-left corner and to the right of the bottom-right corner */ - if (!check_extents (phase, cr2, FILL, EQUALS, 10, 10, 80, 80) || - !check_extents (phase, cr2, STROKE, CONTAINS, 0, 5, 95, 95) || - !check_extents (phase, cr2, PATH, CONTAINS, 10, 10, 80, 80)) - ret = CAIRO_TEST_FAILURE; + errors += !check_extents (phase, cr2, FILL, EQUALS, 10, 10, 80, 80); + errors += !check_extents (phase, cr2, STROKE, CONTAINS, 0, 5, 95, 95); + errors += !check_extents (phase, cr2, PATH, CONTAINS, 10, 10, 80, 80); cairo_new_path (cr2); cairo_restore (cr2); @@ -253,19 +242,17 @@ draw (cairo_t *cr, int width, int height) cairo_set_fill_rule (cr2, CAIRO_FILL_RULE_EVEN_ODD); phase = "EVEN_ODD overlapping rectangles"; - if (!check_extents (phase, cr2, FILL, EQUALS, 10, 10, 15, 30) || - !check_extents (phase, cr2, STROKE, EQUALS, 8, 8, 34, 34) || - !check_extents (phase, cr2, PATH, EQUALS, 10, 10, 30, 30)) - ret = CAIRO_TEST_FAILURE; + errors += !check_extents (phase, cr2, FILL, EQUALS, 10, 10, 15, 30); + errors += !check_extents (phase, cr2, STROKE, EQUALS, 8, 8, 34, 34); + errors += !check_extents (phase, cr2, PATH, EQUALS, 10, 10, 30, 30); /* Test other fill rule with the same path. */ cairo_set_fill_rule (cr2, CAIRO_FILL_RULE_WINDING); phase = "WINDING overlapping rectangles"; - if (!check_extents (phase, cr2, FILL, EQUALS, 10, 10, 30, 30) || - !check_extents (phase, cr2, STROKE, EQUALS, 8, 8, 34, 34) || - !check_extents (phase, cr2, PATH, EQUALS, 10, 10, 30, 30)) - ret = CAIRO_TEST_FAILURE; + errors += !check_extents (phase, cr2, FILL, EQUALS, 10, 10, 30, 30); + errors += !check_extents (phase, cr2, STROKE, EQUALS, 8, 8, 34, 34); + errors += !check_extents (phase, cr2, PATH, EQUALS, 10, 10, 30, 30); /* Now, change the direction of the second rectangle and test both * fill rules again. */ @@ -275,19 +262,17 @@ draw (cairo_t *cr, int width, int height) cairo_set_fill_rule (cr2, CAIRO_FILL_RULE_EVEN_ODD); phase = "EVEN_ODD overlapping rectangles"; - if (!check_extents (phase, cr2, FILL, EQUALS, 10, 10, 15, 30) || - !check_extents (phase, cr2, STROKE, EQUALS, 8, 8, 34, 34) || - !check_extents (phase, cr2, PATH, EQUALS, 10, 10, 30, 30)) - ret = CAIRO_TEST_FAILURE; + errors += !check_extents (phase, cr2, FILL, EQUALS, 10, 10, 15, 30); + errors += !check_extents (phase, cr2, STROKE, EQUALS, 8, 8, 34, 34); + errors += !check_extents (phase, cr2, PATH, EQUALS, 10, 10, 30, 30); /* Test other fill rule with the same path. */ cairo_set_fill_rule (cr2, CAIRO_FILL_RULE_WINDING); phase = "WINDING overlapping rectangles"; - if (!check_extents (phase, cr2, FILL, EQUALS, 10, 10, 15, 30) || - !check_extents (phase, cr2, STROKE, EQUALS, 8, 8, 34, 34) || - !check_extents (phase, cr2, PATH, EQUALS, 10, 10, 30, 30)) - ret = CAIRO_TEST_FAILURE; + errors += !check_extents (phase, cr2, FILL, EQUALS, 10, 10, 15, 30); + errors += !check_extents (phase, cr2, STROKE, EQUALS, 8, 8, 34, 34); + errors += !check_extents (phase, cr2, PATH, EQUALS, 10, 10, 30, 30); cairo_new_path (cr2); @@ -298,8 +283,7 @@ draw (cairo_t *cr, int width, int height) cairo_save (cr2); cairo_arc (cr2, 250.0, 250.0, 157.0, 5.147, 3.432); cairo_set_line_width (cr2, 154.0); - if (!check_extents (phase, cr2, STROKE, APPROX_EQUALS, 16, 38, 468, 446)) - ret = CAIRO_TEST_FAILURE; + errors += !check_extents (phase, cr2, STROKE, APPROX_EQUALS, 16, 38, 468, 446); cairo_new_path (cr2); cairo_restore (cr2); @@ -325,16 +309,15 @@ draw (cairo_t *cr, int width, int height) extents.y_bearing, extents.width, extents.height); - ret = CAIRO_TEST_FAILURE; + errors++; } cairo_move_to (cr2, -extents.x_bearing, -extents.y_bearing); cairo_text_path (cr2, string); cairo_set_line_width (cr2, 2.0); - if (!check_extents (phase, cr2, FILL, EQUALS, 0, 0, extents.width, extents.height) || - !check_extents (phase, cr2, STROKE, EQUALS, -1, -1, extents.width+2, extents.height+2) || - !check_extents (phase, cr2, PATH, EQUALS, 0, 0, extents.width, extents.height)) - ret = CAIRO_TEST_FAILURE; + errors += !check_extents (phase, cr2, FILL, EQUALS, 0, 0, extents.width, extents.height); + errors += !check_extents (phase, cr2, STROKE, EQUALS, -1, -1, extents.width+2, extents.height+2); + errors += !check_extents (phase, cr2, PATH, EQUALS, 0, 0, extents.width, extents.height); cairo_new_path (cr2); cairo_restore (cr2); @@ -342,10 +325,9 @@ draw (cairo_t *cr, int width, int height) cairo_save (cr2); cairo_scale (cr2, 2, 2); cairo_rectangle (cr2, 5, 5, 40, 40); - if (!check_extents (phase, cr2, FILL, EQUALS, 5, 5, 40, 40) || - !check_extents (phase, cr2, STROKE, EQUALS, 0, 0, 50, 50) || - !check_extents (phase, cr2, PATH, EQUALS, 5, 5, 40, 40)) - ret = CAIRO_TEST_FAILURE; + errors += !check_extents (phase, cr2, FILL, EQUALS, 5, 5, 40, 40); + errors += !check_extents (phase, cr2, STROKE, EQUALS, 0, 0, 50, 50); + errors += !check_extents (phase, cr2, PATH, EQUALS, 5, 5, 40, 40); cairo_new_path (cr2); cairo_restore (cr2); @@ -355,10 +337,9 @@ draw (cairo_t *cr, int width, int height) cairo_scale (cr2, 2, 2); cairo_rectangle (cr2, 5, 5, 40, 40); cairo_restore (cr2); - if (!check_extents (phase, cr2, FILL, EQUALS, 10, 10, 80, 80) || - !check_extents (phase, cr2, STROKE, EQUALS, 5, 5, 90, 90) || - !check_extents (phase, cr2, PATH, EQUALS, 10, 10, 80, 80)) - ret = CAIRO_TEST_FAILURE; + errors += !check_extents (phase, cr2, FILL, EQUALS, 10, 10, 80, 80); + errors += !check_extents (phase, cr2, STROKE, EQUALS, 5, 5, 90, 90); + errors += !check_extents (phase, cr2, PATH, EQUALS, 10, 10, 80, 80); cairo_new_path (cr2); cairo_restore (cr2); @@ -375,15 +356,15 @@ draw (cairo_t *cr, int width, int height) the axes. With the stroke width added to the rotated path, the largest axis-aligned square is a bit over 38 on either side of the axes. */ - if (!check_extents (phase, cr2, FILL, CONTAINS, -35, -35, 35, 35) || - !check_extents (phase, cr2, STROKE, CONTAINS, -38, -38, 38, 38) || - !check_extents (phase, cr2, PATH, CONTAINS, -35, -35, 35, 35)) - ret = CAIRO_TEST_FAILURE; + errors += !check_extents (phase, cr2, FILL, CONTAINS, -35, -35, 35, 35); + errors += !check_extents (phase, cr2, STROKE, CONTAINS, -38, -38, 38, 38); + errors += !check_extents (phase, cr2, PATH, CONTAINS, -35, -35, 35, 35); cairo_new_path (cr2); cairo_restore (cr2); cairo_destroy (cr2); - return ret; + + return errors == 0 ? CAIRO_TEST_SUCCESS : CAIRO_TEST_FAILURE; } int |