summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2020-12-20 11:50:22 -0500
committerMatthias Clasen <mclasen@redhat.com>2021-12-04 22:58:23 -0500
commit021bca4629d77916520ed89646ba77d30af2e85b (patch)
tree8e7a2334f343edb497531ae669dc712d53c33972
parentf91995db06512ba9cee0ddeb4b521b6113c8e4c8 (diff)
downloadgtk+-021bca4629d77916520ed89646ba77d30af2e85b.tar.gz
Add a test for gsk_curve_reverse
The stroker relies on this working.
-rw-r--r--testsuite/gsk/curve.c47
1 files changed, 47 insertions, 0 deletions
diff --git a/testsuite/gsk/curve.c b/testsuite/gsk/curve.c
index 5b5af1fadd..2588ed2706 100644
--- a/testsuite/gsk/curve.c
+++ b/testsuite/gsk/curve.c
@@ -465,6 +465,52 @@ test_curve_split (void)
}
}
+/* Test that reversing curves of all types produces the
+ * expected result
+ */
+static void
+test_curve_reverse (void)
+{
+ GskCurve c, r;
+ graphene_point_t p[4];
+
+ graphene_point_init (&p[0], 0, 0);
+ graphene_point_init (&p[1], 50, 50);
+ gsk_curve_init (&c, gsk_pathop_encode (GSK_PATH_LINE, p));
+
+ gsk_curve_reverse (&c, &r);
+
+ g_assert_true (r.op == GSK_PATH_LINE);
+ g_assert_true (graphene_point_equal (&r.line.points[0], &p[1]));
+ g_assert_true (graphene_point_equal (&r.line.points[1], &p[0]));
+
+ graphene_point_init (&p[0], 0, 0);
+ graphene_point_init (&p[1], 50, 50);
+ graphene_point_init (&p[2], 100, 50);
+ graphene_point_init (&p[3], 200, 0);
+ gsk_curve_init (&c, gsk_pathop_encode (GSK_PATH_CURVE, p));
+
+ gsk_curve_reverse (&c, &r);
+ g_assert_true (r.op == GSK_PATH_CURVE);
+ g_assert_true (graphene_point_equal (&r.curve.points[0], &p[3]));
+ g_assert_true (graphene_point_equal (&r.curve.points[1], &p[2]));
+ g_assert_true (graphene_point_equal (&r.curve.points[2], &p[1]));
+ g_assert_true (graphene_point_equal (&r.curve.points[3], &p[0]));
+
+ graphene_point_init (&p[0], 0, 0);
+ graphene_point_init (&p[1], 50, 50);
+ graphene_point_init (&p[2], 100, 50);
+ gsk_curve_init_foreach (&c, GSK_PATH_CONIC, p, 3, 20);
+
+ gsk_curve_reverse (&c, &r);
+ g_assert_true (r.op == GSK_PATH_CONIC);
+ g_assert_true (r.conic.points[2].x == 20);
+
+ g_assert_true (graphene_point_equal (&r.conic.points[0], &c.conic.points[3]));
+ g_assert_true (graphene_point_equal (&r.conic.points[1], &c.conic.points[1]));
+ g_assert_true (graphene_point_equal (&r.conic.points[3], &c.conic.points[0]));
+}
+
int
main (int argc, char *argv[])
{
@@ -479,6 +525,7 @@ main (int argc, char *argv[])
g_test_add_func ("/curve/intersection/curve-curve", test_curve_curve_intersection);
g_test_add_func ("/curve/intersection/horizontal-line", test_curve_intersection_horizontal_line);
g_test_add_func ("/curve/split", test_curve_split);
+ g_test_add_func ("/curve/reverse", test_curve_reverse);
return g_test_run ();
}