summaryrefslogtreecommitdiff
path: root/test/in-fill-trapezoid.c
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2008-11-06 01:02:23 +0000
committerChris Wilson <chris@chris-wilson.co.uk>2008-11-06 01:06:20 +0000
commit9dee7af41f4f5a4c1285e9d7951148e78659c064 (patch)
tree8adbe35acdd3c01d3857224867bac94917762cd1 /test/in-fill-trapezoid.c
parentf5965cb7d6559e051c2581fe446d0b9f40427eb2 (diff)
downloadcairo-9dee7af41f4f5a4c1285e9d7951148e78659c064.tar.gz
[test] Add off-centre tests to in-fill-trapezoid.
Reading through the previous commit spotted that the arguments to edge_compare_for_y_against_x were transposed, but the test-suite had failed to catch detect it. This is due that in order to actually solve the equation we need to have a diagonal edge passing near an off-centre point of interest, which was not among the test cases. So add some off-centre tests to fully exercise the code.
Diffstat (limited to 'test/in-fill-trapezoid.c')
-rw-r--r--test/in-fill-trapezoid.c66
1 files changed, 66 insertions, 0 deletions
diff --git a/test/in-fill-trapezoid.c b/test/in-fill-trapezoid.c
index f38f97daa..717a87a06 100644
--- a/test/in-fill-trapezoid.c
+++ b/test/in-fill-trapezoid.c
@@ -124,6 +124,72 @@ draw (cairo_t *cr, int width, int height)
ret = CAIRO_TEST_FAILURE;
}
+ /* check off-centre */
+ cairo_new_path (cr);
+ cairo_arc (cr, 7.5, 0, 10, 0, 2 * M_PI);
+ cairo_arc_negative (cr, 7.5, 0, 5, 0, -2 * M_PI);
+ if (cairo_in_fill (cr, 7.5, 0)) {
+ cairo_test_log (ctx, "Error: Found an unexpected point inside circular hole\n");
+ ret = CAIRO_TEST_FAILURE;
+ }
+ cairo_new_path (cr);
+ cairo_arc (cr, 0, 7.5, 10, 0, 2 * M_PI);
+ cairo_arc_negative (cr, 0, 7.5, 5, 0, -2 * M_PI);
+ if (cairo_in_fill (cr, 0, 7.5)) {
+ cairo_test_log (ctx, "Error: Found an unexpected point inside circular hole\n");
+ ret = CAIRO_TEST_FAILURE;
+ }
+ cairo_new_path (cr);
+ cairo_arc (cr, 15, 0, 10, 0, 2 * M_PI);
+ if (! cairo_in_fill (cr, 15, 0)) {
+ cairo_test_log (ctx, "Error: Failed to find point inside circle\n");
+ ret = CAIRO_TEST_FAILURE;
+ }
+ cairo_new_path (cr);
+ cairo_arc (cr, 0, 15, 10, 0, 2 * M_PI);
+ if (! cairo_in_fill (cr, 0, 15)) {
+ cairo_test_log (ctx, "Error: Failed to find point inside circle\n");
+ ret = CAIRO_TEST_FAILURE;
+ }
+
+ /* simple rectangle */
+ cairo_new_path (cr);
+ cairo_rectangle (cr, 10, 0, 5, 5);
+ if (cairo_in_fill (cr, 0, 0)) {
+ cairo_test_log (ctx, "Error: Found an unexpected point outside rectangle\n");
+ ret = CAIRO_TEST_FAILURE;
+ }
+ if (cairo_in_fill (cr, 20, 20)) {
+ cairo_test_log (ctx, "Error: Found an unexpected point outside rectangle\n");
+ ret = CAIRO_TEST_FAILURE;
+ }
+ if (! cairo_in_fill (cr, 12.5, 2.5)) {
+ cairo_test_log (ctx, "Error: Failed to find point inside rectangle\n");
+ ret = CAIRO_TEST_FAILURE;
+ }
+
+ /* off-centre triangle */
+ cairo_new_path (cr);
+ cairo_move_to (cr, 10, 0);
+ cairo_line_to (cr, 15, 5);
+ cairo_line_to (cr, 5, 5);
+ cairo_close_path (cr);
+ if (cairo_in_fill (cr, 0, 0) ||
+ cairo_in_fill (cr, 10, 10) ||
+ cairo_in_fill (cr, 20, 0) ||
+ cairo_in_fill (cr, 7, 2.5) ||
+ cairo_in_fill (cr, 13, 2.5))
+ {
+ cairo_test_log (ctx, "Error: Found an unexpected point outside triangle\n");
+ ret = CAIRO_TEST_FAILURE;
+ }
+ if (! cairo_in_fill (cr, 8, 2.5) ||
+ ! cairo_in_fill (cr, 12, 2.5))
+ {
+ cairo_test_log (ctx, "Error: Failed to find point inside triangle\n");
+ ret = CAIRO_TEST_FAILURE;
+ }
+
return ret;
}