[gtk/curve-ops: 4/10] Add curve tangent tests
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/curve-ops: 4/10] Add curve tangent tests
- Date: Mon, 7 Dec 2020 23:46:26 +0000 (UTC)
commit 5db10d73330597a787472f3ae6f8b2a6e744c598
Author: Matthias Clasen <mclasen redhat com>
Date: Mon Dec 7 11:51:47 2020 -0500
Add curve tangent tests
testsuite/gsk/curve.c | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 50 insertions(+)
---
diff --git a/testsuite/gsk/curve.c b/testsuite/gsk/curve.c
index 3afaad9a60..b48e4fbbd9 100644
--- a/testsuite/gsk/curve.c
+++ b/testsuite/gsk/curve.c
@@ -69,12 +69,62 @@ test_curve_points (void)
}
}
+static void
+test_curve_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], 100, 0);
+ gsk_curve_init (&c, gsk_pathop_encode (GSK_PATH_LINE, 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], 0, 100);
+ gsk_curve_init (&c, gsk_pathop_encode (GSK_PATH_LINE, p));
+
+ gsk_curve_get_start_tangent (&c, &t);
+ g_assert_true (graphene_vec2_near (&t, graphene_vec2_y_axis (), 0.0001));
+ gsk_curve_get_end_tangent (&c, &t);
+ g_assert_true (graphene_vec2_near (&t, graphene_vec2_y_axis (), 0.0001));
+
+ graphene_point_init (&p[0], 0, 0);
+ graphene_point_init (&p[1], 100, 0);
+ p[2] = GRAPHENE_POINT_INIT (g_test_rand_double_range (0, 20), 0);
+ graphene_point_init (&p[3], 100, 100);
+ gsk_curve_init (&c, gsk_pathop_encode (GSK_PATH_CONIC, 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_y_axis (), 0.0001));
+
+ graphene_point_init (&p[0], 0, 0);
+ graphene_point_init (&p[1], 50, 0);
+ graphene_point_init (&p[2], 100, 50);
+ graphene_point_init (&p[3], 100, 100);
+ 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_y_axis (), 0.0001));
+}
+
int
main (int argc, char *argv[])
{
g_test_init (&argc, &argv, NULL);
g_test_add_func ("/curve/points", test_curve_points);
+ g_test_add_func ("/curve/tangents", test_curve_tangents);
return g_test_run ();
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]