[test/in-fill-trapezoid] Add test to exercise _cairo_trap_contains().

A simple test to provide coverage of _cairo_trap_contains(), though
not yet seeking boundary conditions.
This commit is contained in:
Chris Wilson 2008-01-17 11:22:19 +00:00
parent f638e5ea35
commit da9c43329a
3 changed files with 68 additions and 0 deletions

1
test/.gitignore vendored
View file

@ -71,6 +71,7 @@ gradient-zero-stops
imagediff
infinite-join
in-fill-empty-trapezoid
in-fill-trapezoid
invalid-matrix
leaky-dash
leaky-polygon

View file

@ -54,6 +54,7 @@ gradient-alpha$(EXEEXT) \
gradient-zero-stops$(EXEEXT) \
infinite-join$(EXEEXT) \
in-fill-empty-trapezoid$(EXEEXT) \
in-fill-trapezoid$(EXEEXT) \
invalid-matrix$(EXEEXT) \
leaky-dash$(EXEEXT) \
leaky-polygon$(EXEEXT) \

66
test/in-fill-trapezoid.c Normal file
View file

@ -0,0 +1,66 @@
/*
* Copyright © 2008 Chris Wilson
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use, copy,
* modify, merge, publish, distribute, sublicense, and/or sell copies
* of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
* Author: Chris Wilson <chris@chris-wilson.co.uk>
*/
#include "cairo-test.h"
static cairo_test_draw_function_t draw;
cairo_test_t test = {
"in-fill-trapezoid",
"Test _cairo_trap_contains via cairo_in_fill",
0, 0,
draw
};
static cairo_test_status_t
draw (cairo_t *cr, int width, int height)
{
cairo_test_status_t ret = CAIRO_TEST_SUCCESS;
/* simple rectangle */
cairo_new_path (cr);
cairo_rectangle (cr, -10, -10, 20, 20);
if (! cairo_in_fill (cr, 0, 0)) {
cairo_test_log ("Error: Failed to find point inside rectangle\n");
ret = CAIRO_TEST_FAILURE;
}
/* simple circle */
cairo_new_path (cr);
cairo_arc (cr, 0, 0, 10, 0, 2 * M_PI);
if (! cairo_in_fill (cr, 0, 0)) {
cairo_test_log ("Error: Failed to find point inside circle\n");
ret = CAIRO_TEST_FAILURE;
}
return ret;
}
int
main (void)
{
return cairo_test (&test);
}