[pango/matrix-decompose: 2/3] Add a minimal test for pango_matrix_decompose
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pango/matrix-decompose: 2/3] Add a minimal test for pango_matrix_decompose
- Date: Mon, 20 Dec 2021 02:53:38 +0000 (UTC)
commit 0cbd693d96d0b2338cef5795d03d6b670368d24a
Author: Matthias Clasen <mclasen redhat com>
Date: Sun Dec 19 21:23:02 2021 -0500
Add a minimal test for pango_matrix_decompose
More comprehensive tests for this are needed.
tests/testmatrix.c | 23 +++++++++++++++++++++++
1 file changed, 23 insertions(+)
---
diff --git a/tests/testmatrix.c b/tests/testmatrix.c
index 607f2b5f..87c3a97a 100644
--- a/tests/testmatrix.c
+++ b/tests/testmatrix.c
@@ -20,6 +20,7 @@
*/
#include <glib.h>
+#include <math.h>
#include <pango/pango.h>
#define matrix_equal(m1, m2) \
@@ -185,6 +186,27 @@ test_matrix_transform_pixel_rect (void)
g_assert_cmpfloat_with_epsilon (rect.height, 2, 0.1);
}
+#define DEG_TO_RAD(x) ((x) / 180. * G_PI)
+
+static void
+test_matrix_decompose (void)
+{
+ PangoMatrix m;
+ double skew_x, skew_y, scale_x, scale_y, angle, dx, dy;
+
+ m = (PangoMatrix) { 1, 0, tan (DEG_TO_RAD (20)), 1, 0, 0 };
+
+ pango_matrix_decompose (&m, &skew_x, &skew_y, &scale_x, &scale_y, &angle, &dx, &dy);
+
+ g_assert_cmpfloat (skew_x, ==, 20);
+ g_assert_cmpfloat (skew_y, ==, 0);
+ g_assert_cmpfloat (scale_x, ==, 1);
+ g_assert_cmpfloat (scale_y, ==, 1);
+ g_assert_cmpfloat (angle, ==, 0);
+ g_assert_cmpfloat (dx, ==, 0);
+ g_assert_cmpfloat (dy, ==, 0);
+}
+
int
main (int argc, char *argv[])
{
@@ -199,6 +221,7 @@ main (int argc, char *argv[])
g_test_add_func ("/matrix/transform-distance", test_matrix_transform_distance);
g_test_add_func ("/matrix/transform-rect", test_matrix_transform_rect);
g_test_add_func ("/matrix/transform-pixel-rect", test_matrix_transform_pixel_rect);
+ g_test_add_func ("/matrix/decompose", test_matrix_decompose);
return g_test_run ();
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]