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.
26 _adg_property_angle(void)
28 AdgRuledFill
*ruled_fill
;
31 ruled_fill
= adg_ruled_fill_new();
33 /* Using the public APIs */
34 adg_ruled_fill_set_angle(ruled_fill
, G_PI_2
);
35 angle
= adg_ruled_fill_get_angle(ruled_fill
);
36 adg_assert_isapprox(angle
, G_PI_2
);
38 adg_ruled_fill_set_angle(ruled_fill
, G_PI
+ 1);
39 angle
= adg_ruled_fill_get_angle(ruled_fill
);
40 adg_assert_isapprox(angle
, G_PI_2
);
42 adg_ruled_fill_set_angle(ruled_fill
, -1);
43 angle
= adg_ruled_fill_get_angle(ruled_fill
);
44 adg_assert_isapprox(angle
, G_PI_2
);
46 adg_ruled_fill_set_angle(ruled_fill
, 0);
47 angle
= adg_ruled_fill_get_angle(ruled_fill
);
48 adg_assert_isapprox(angle
, 0);
50 /* Using GObject property methods */
51 g_object_set(ruled_fill
, "angle", G_PI_2
, NULL
);
52 g_object_get(ruled_fill
, "angle", &angle
, NULL
);
53 adg_assert_isapprox(angle
, G_PI_2
);
55 g_object_set(ruled_fill
, "angle", G_PI
+ 1, NULL
);
56 g_object_get(ruled_fill
, "angle", &angle
, NULL
);
57 adg_assert_isapprox(angle
, G_PI_2
);
59 g_object_set(ruled_fill
, "angle", (gdouble
) -1, NULL
);
60 g_object_get(ruled_fill
, "angle", &angle
, NULL
);
61 adg_assert_isapprox(angle
, G_PI_2
);
63 g_object_set(ruled_fill
, "angle", (gdouble
) 0, NULL
);
64 g_object_get(ruled_fill
, "angle", &angle
, NULL
);
65 adg_assert_isapprox(angle
, 0);
67 g_object_unref(ruled_fill
);
71 _adg_property_line_dress(void)
73 AdgRuledFill
*ruled_fill
;
74 AdgDress valid_dress_1
, valid_dress_2
, incompatible_dress
;
77 ruled_fill
= adg_ruled_fill_new();
78 valid_dress_1
= ADG_DRESS_LINE_AXIS
;
79 valid_dress_2
= ADG_DRESS_LINE_HIDDEN
;
80 incompatible_dress
= ADG_DRESS_TABLE
;
82 /* Using the public APIs */
83 adg_ruled_fill_set_line_dress(ruled_fill
, valid_dress_1
);
84 line_dress
= adg_ruled_fill_get_line_dress(ruled_fill
);
85 g_assert_cmpint(line_dress
, ==, valid_dress_1
);
87 adg_ruled_fill_set_line_dress(ruled_fill
, incompatible_dress
);
88 line_dress
= adg_ruled_fill_get_line_dress(ruled_fill
);
89 g_assert_cmpint(line_dress
, ==, valid_dress_1
);
91 adg_ruled_fill_set_line_dress(ruled_fill
, valid_dress_2
);
92 line_dress
= adg_ruled_fill_get_line_dress(ruled_fill
);
93 g_assert_cmpint(line_dress
, ==, valid_dress_2
);
95 /* Using GObject property methods */
96 g_object_set(ruled_fill
, "line-dress", valid_dress_1
, NULL
);
97 g_object_get(ruled_fill
, "line-dress", &line_dress
, NULL
);
98 g_assert_cmpint(line_dress
, ==, valid_dress_1
);
100 g_object_set(ruled_fill
, "line-dress", incompatible_dress
, NULL
);
101 g_object_get(ruled_fill
, "line-dress", &line_dress
, NULL
);
102 g_assert_cmpint(line_dress
, ==, valid_dress_1
);
104 g_object_set(ruled_fill
, "line-dress", valid_dress_2
, NULL
);
105 g_object_get(ruled_fill
, "line-dress", &line_dress
, NULL
);
106 g_assert_cmpint(line_dress
, ==, valid_dress_2
);
108 g_object_unref(ruled_fill
);
112 _adg_property_spacing(void)
114 AdgRuledFill
*ruled_fill
;
117 ruled_fill
= adg_ruled_fill_new();
119 /* Using the public APIs */
120 adg_ruled_fill_set_spacing(ruled_fill
, 0);
121 spacing
= adg_ruled_fill_get_spacing(ruled_fill
);
122 adg_assert_isapprox(spacing
, 0);
124 adg_ruled_fill_set_spacing(ruled_fill
, -1);
125 spacing
= adg_ruled_fill_get_spacing(ruled_fill
);
126 adg_assert_isapprox(spacing
, 0);
128 adg_ruled_fill_set_spacing(ruled_fill
, 123);
129 spacing
= adg_ruled_fill_get_spacing(ruled_fill
);
130 adg_assert_isapprox(spacing
, 123);
132 /* Using GObject property methods */
133 g_object_set(ruled_fill
, "spacing", (gdouble
) 0, NULL
);
134 g_object_get(ruled_fill
, "spacing", &spacing
, NULL
);
135 adg_assert_isapprox(spacing
, 0);
137 g_object_set(ruled_fill
, "spacing", (gdouble
) -1, NULL
);
138 g_object_get(ruled_fill
, "spacing", &spacing
, NULL
);
139 adg_assert_isapprox(spacing
, 0);
141 g_object_set(ruled_fill
, "spacing", (gdouble
) 123, NULL
);
142 g_object_get(ruled_fill
, "spacing", &spacing
, NULL
);
143 adg_assert_isapprox(spacing
, 123);
145 g_object_unref(ruled_fill
);
150 main(int argc
, char *argv
[])
152 adg_test_init(&argc
, &argv
);
154 adg_test_add_object_checks("/adg/ruled-fill/type/object", ADG_TYPE_RULED_FILL
);
156 g_test_add_func("/adg/ruled-fill/property/angle", _adg_property_angle
);
157 g_test_add_func("/adg/ruled-fill/property/line-dress", _adg_property_line_dress
);
158 g_test_add_func("/adg/ruled-fill/property/spacing", _adg_property_spacing
);