[gtk/path-work-rebased: 73/105] Add a test for tangents of degenerate curves
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/path-work-rebased: 73/105] Add a test for tangents of degenerate curves
- Date: Fri, 8 Apr 2022 17:20:44 +0000 (UTC)
commit c4fcfbaef85943821d1bc4de4492b4fd2bbd06cb
Author: Matthias Clasen <mclasen redhat com>
Date: Sun Dec 20 11:19:43 2020 -0500
Add a test for tangents of degenerate curves
The stroker relies on these to work.
testsuite/gsk/curve-special-cases.c | 33 +++++++++++++++++++++++++++++++--
1 file changed, 31 insertions(+), 2 deletions(-)
---
diff --git a/testsuite/gsk/curve-special-cases.c b/testsuite/gsk/curve-special-cases.c
index 820cb73d59..d8dd0274ba 100644
--- a/testsuite/gsk/curve-special-cases.c
+++ b/testsuite/gsk/curve-special-cases.c
@@ -87,7 +87,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));
@@ -120,6 +119,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_CURVE, 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_CURVE, 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 void
test_errant_intersection (void)
{
@@ -258,7 +287,6 @@ test_line_intersection_parallel (void)
g_assert_cmpfloat_with_epsilon (t1[1], 0.5, 0.001);
g_assert_cmpfloat_with_epsilon (t2[0], 0.5, 0.001);
g_assert_cmpfloat_with_epsilon (t2[1], 1, 0.001);
-
}
int
@@ -269,6 +297,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/errant-intersection", test_errant_intersection);
g_test_add_func ("/curve/errant-intersection2", test_errant_intersection2);
g_test_add_func ("/curve/line-intersection-parallel", test_line_intersection_parallel);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]