doc: update copyright line for 2021
[adg.git] / src / adg / tests / test-pango-style.c
blobb6412d9f38c0b5e03914e07c3ba51dca0d28e772
1 /* ADG - Automatic Drawing Generation
2 * Copyright (C) 2007-2021 Nicola Fontana <ntd at entidi.it>
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the
16 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
21 #include <adg-test.h>
22 #include <adg.h>
25 static void
26 _adg_property_spacing(void)
28 AdgPangoStyle *pango_style;
29 gint valid_spacing_1, valid_spacing_2;
30 gint spacing;
32 pango_style = adg_pango_style_new();
33 valid_spacing_1 = 123;
34 valid_spacing_2 = -123;
36 /* Using the public APIs */
37 adg_pango_style_set_spacing(pango_style, valid_spacing_1);
38 spacing = adg_pango_style_get_spacing(pango_style);
39 g_assert_cmpint(spacing, ==, valid_spacing_1);
41 adg_pango_style_set_spacing(pango_style, valid_spacing_2);
42 spacing = adg_pango_style_get_spacing(pango_style);
43 g_assert_cmpint(spacing, ==, valid_spacing_2);
45 /* Using GObject property methods */
46 g_object_set(pango_style, "spacing", valid_spacing_1, NULL);
47 g_object_get(pango_style, "spacing", &spacing, NULL);
48 g_assert_cmpint(spacing, ==, valid_spacing_1);
50 g_object_set(pango_style, "spacing", valid_spacing_2, NULL);
51 g_object_get(pango_style, "spacing", &spacing, NULL);
52 g_assert_cmpint(spacing, ==, valid_spacing_2);
54 /* Check improper use */
55 adg_pango_style_set_spacing(NULL, 111);
56 spacing = adg_pango_style_get_spacing(NULL);
57 g_assert_cmpint(spacing, ==, 0);
58 spacing = adg_pango_style_get_spacing(pango_style);
59 g_assert_cmpint(spacing, ==, valid_spacing_2);
61 g_object_unref(pango_style);
64 static void
65 _adg_method_get_description(void)
67 AdgPangoStyle *pango_style;
68 PangoFontDescription *description;
70 pango_style = adg_pango_style_new();
72 /* Check valid use */
73 description = adg_pango_style_get_description(pango_style);
74 g_assert_nonnull(description);
76 /* Check improper use */
77 description = adg_pango_style_get_description(NULL);
78 g_assert_null(description);
80 g_object_unref(pango_style);
84 int
85 main(int argc, char *argv[])
87 adg_test_init(&argc, &argv);
89 adg_test_add_object_checks("/adg/font-style/type/object", ADG_TYPE_PANGO_STYLE);
91 g_test_add_func("/adg/pango-style/property/spacing", _adg_property_spacing);
93 g_test_add_func("/adg/pango-style/get_description", _adg_method_get_description);
95 return g_test_run();