Add a curve bounds test
This commit is contained in:
@@ -118,6 +118,33 @@ test_curve_tangents (void)
|
||||
g_assert_true (graphene_vec2_near (&t, graphene_vec2_y_axis (), 0.0001));
|
||||
}
|
||||
|
||||
static void
|
||||
test_curve_bounds (void)
|
||||
{
|
||||
for (int i = 0; i < 100; i++)
|
||||
{
|
||||
GskCurve c;
|
||||
graphene_rect_t bounds;
|
||||
graphene_rect_t hull;
|
||||
|
||||
init_random_curve (&c);
|
||||
gsk_curve_get_bounds (&c, &hull);
|
||||
gsk_curve_get_tight_bounds (&c, &bounds);
|
||||
|
||||
graphene_rect_inset (&hull, - 0.5, - 0.5); // FIXME: this seems big
|
||||
g_assert_true (graphene_rect_contains_rect (&hull, &bounds));
|
||||
graphene_rect_inset (&bounds, - 0.5, - 0.5);
|
||||
|
||||
for (int j = 0; j < 100; j++)
|
||||
{
|
||||
graphene_point_t p;
|
||||
|
||||
gsk_curve_eval (&c, j / 99.0, &p, NULL);
|
||||
g_assert_true (graphene_rect_contains_point (&bounds, &p));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
main (int argc, char *argv[])
|
||||
{
|
||||
@@ -125,6 +152,7 @@ main (int argc, char *argv[])
|
||||
|
||||
g_test_add_func ("/curve/points", test_curve_points);
|
||||
g_test_add_func ("/curve/tangents", test_curve_tangents);
|
||||
g_test_add_func ("/curve/bounds", test_curve_bounds);
|
||||
|
||||
return g_test_run ();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user