diff --git a/testsuite/gsk/curve-special-cases.c b/testsuite/gsk/curve-special-cases.c index afd45c4258..88683a051d 100644 --- a/testsuite/gsk/curve-special-cases.c +++ b/testsuite/gsk/curve-special-cases.c @@ -88,7 +88,6 @@ test_curve_tangents (void) gsk_curve_get_end_tangent (&c, &t); g_assert_true (graphene_vec2_near (&t, graphene_vec2_x_axis (), 0.0001)); - graphene_point_init (&p[0], 0, 0); graphene_point_init (&p[1], 0, 100); gsk_curve_init (&c, gsk_pathop_encode (GSK_PATH_LINE, p)); @@ -121,6 +120,36 @@ test_curve_tangents (void) g_assert_true (graphene_vec2_near (&t, graphene_vec2_y_axis (), 0.0001)); } +static void +test_curve_degenerate_tangents (void) +{ + GskCurve c; + graphene_point_t p[4]; + graphene_vec2_t t; + + graphene_point_init (&p[0], 0, 0); + graphene_point_init (&p[1], 0, 0); + graphene_point_init (&p[2], 100, 0); + graphene_point_init (&p[3], 100, 0); + gsk_curve_init (&c, gsk_pathop_encode (GSK_PATH_CUBIC, p)); + + gsk_curve_get_start_tangent (&c, &t); + g_assert_true (graphene_vec2_near (&t, graphene_vec2_x_axis (), 0.0001)); + gsk_curve_get_end_tangent (&c, &t); + g_assert_true (graphene_vec2_near (&t, graphene_vec2_x_axis (), 0.0001)); + + graphene_point_init (&p[0], 0, 0); + graphene_point_init (&p[1], 50, 0); + graphene_point_init (&p[2], 50, 0); + graphene_point_init (&p[3], 100, 0); + gsk_curve_init (&c, gsk_pathop_encode (GSK_PATH_CUBIC, p)); + + gsk_curve_get_start_tangent (&c, &t); + g_assert_true (graphene_vec2_near (&t, graphene_vec2_x_axis (), 0.0001)); + gsk_curve_get_end_tangent (&c, &t); + g_assert_true (graphene_vec2_near (&t, graphene_vec2_x_axis (), 0.0001)); +} + static gboolean near_one_point (const graphene_point_t *p, const graphene_point_t *q, @@ -286,6 +315,7 @@ main (int argc, g_test_add_func ("/curve/special/conic-segment", test_conic_segment); g_test_add_func ("/curve/special/tangents", test_curve_tangents); + g_test_add_func ("/curve/special/degenerate-tangents", test_curve_degenerate_tangents); g_test_add_func ("/curve/special/intersections", test_curve_intersections); return g_test_run ();