[gtk/matthiasc/for-master] testsuite: Improve coverage for rectangles



commit fac7ed154942d88d6370aaa757563bf4c252af96
Author: Matthias Clasen <mclasen redhat com>
Date:   Sat Oct 31 14:57:28 2020 -0400

    testsuite: Improve coverage for rectangles

 testsuite/gdk/rectangle.c | 32 ++++++++++++++++++++++++++++++++
 1 file changed, 32 insertions(+)
---
diff --git a/testsuite/gdk/rectangle.c b/testsuite/gdk/rectangle.c
index ead270eea7..404881025c 100644
--- a/testsuite/gdk/rectangle.c
+++ b/testsuite/gdk/rectangle.c
@@ -1,4 +1,5 @@
 #include <gtk/gtk.h>
+#include <cairo-gobject.h>
 
 static void
 test_rectangle_equal (void)
@@ -65,6 +66,36 @@ test_rectangle_union (void)
   g_assert_true (gdk_rectangle_equal (&f, &g));
 }
 
+/* Test that GdkRectangle works as a boxed type */
+
+static void
+test_rectangle_type (void)
+{
+  GValue value = G_VALUE_INIT;
+  GdkRectangle b = { 5, 5, 10, 10 };
+  GdkRectangle *c;
+  GValue value2 = G_VALUE_INIT;
+  cairo_rectangle_int_t *c2;
+
+  g_value_init (&value, GDK_TYPE_RECTANGLE);
+  g_value_set_boxed (&value, &b);
+  c = g_value_get_boxed (&value);
+
+  g_assert_true (gdk_rectangle_equal (&b, c));
+
+  g_assert_true (g_value_type_transformable (GDK_TYPE_RECTANGLE, CAIRO_GOBJECT_TYPE_RECTANGLE_INT));
+  g_value_init (&value2, CAIRO_GOBJECT_TYPE_RECTANGLE_INT);
+  g_assert_true (g_value_transform (&value, &value2));
+  c2 = g_value_get_boxed (&value2);
+  g_assert_cmpint (c->x, ==, c2->x);
+  g_assert_cmpint (c->y, ==, c2->y);
+  g_assert_cmpint (c->width, ==, c2->width);
+  g_assert_cmpint (c->height, ==, c2->height);
+
+  g_value_unset (&value);
+  g_value_unset (&value2);
+}
+
 int
 main (int argc, char *argv[])
 {
@@ -75,6 +106,7 @@ main (int argc, char *argv[])
   g_test_add_func ("/rectangle/equal", test_rectangle_equal);
   g_test_add_func ("/rectangle/intersect", test_rectangle_intersect);
   g_test_add_func ("/rectangle/union", test_rectangle_union);
+  g_test_add_func ("/rectangle/type", test_rectangle_type);
 
   return g_test_run ();
 }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]