doc: update copyright line for 2021
[adg.git] / src / adg / tests / test-hatch.c
blob8e86f4807b00cb82224e322cb04f0a793890dc54
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_fill_dress(void)
28 AdgHatch *hatch;
29 AdgDress valid_dress_1, valid_dress_2, incompatible_dress;
30 AdgDress fill_dress;
32 hatch = adg_hatch_new(NULL);
33 valid_dress_1 = ADG_DRESS_FILL;
34 valid_dress_2 = ADG_DRESS_FILL_HATCH;
35 incompatible_dress = ADG_DRESS_FONT_TEXT;
37 /* Using the public APIs */
38 adg_hatch_set_fill_dress(hatch, valid_dress_1);
39 fill_dress = adg_hatch_get_fill_dress(hatch);
40 g_assert_cmpint(fill_dress, ==, valid_dress_1);
42 adg_hatch_set_fill_dress(hatch, incompatible_dress);
43 fill_dress = adg_hatch_get_fill_dress(hatch);
44 g_assert_cmpint(fill_dress, ==, valid_dress_1);
46 adg_hatch_set_fill_dress(hatch, valid_dress_2);
47 fill_dress = adg_hatch_get_fill_dress(hatch);
48 g_assert_cmpint(fill_dress, ==, valid_dress_2);
50 /* Using GObject property methods */
51 g_object_set(hatch, "fill-dress", valid_dress_1, NULL);
52 g_object_get(hatch, "fill-dress", &fill_dress, NULL);
53 g_assert_cmpint(fill_dress, ==, valid_dress_1);
55 g_object_set(hatch, "fill-dress", incompatible_dress, NULL);
56 g_object_get(hatch, "fill-dress", &fill_dress, NULL);
57 g_assert_cmpint(fill_dress, ==, valid_dress_1);
59 g_object_set(hatch, "fill-dress", valid_dress_2, NULL);
60 g_object_get(hatch, "fill-dress", &fill_dress, NULL);
61 g_assert_cmpint(fill_dress, ==, valid_dress_2);
63 adg_entity_destroy(ADG_ENTITY(hatch));
67 int
68 main(int argc, char *argv[])
70 AdgPath *path;
72 adg_test_init(&argc, &argv);
74 adg_test_add_object_checks("/adg/hatch/type/object", ADG_TYPE_HATCH);
75 adg_test_add_entity_checks("/adg/hatch/type/entity", ADG_TYPE_HATCH);
77 path = adg_path_new();
78 adg_path_move_to_explicit(path, 1, 2);
79 adg_path_line_to_explicit(path, 4, 5);
80 adg_path_line_to_explicit(path, 7, 8);
81 adg_path_close(path);
82 adg_test_add_global_space_checks("/adg/hatch/behavior/global-space", adg_hatch_new(ADG_TRAIL(path)));
83 adg_test_add_local_space_checks("/adg/hatch/behavior/local-space", adg_hatch_new(ADG_TRAIL(path)));
84 g_object_unref(path);
86 g_test_add_func("/adg/hatch/property/fill-dress", _adg_property_fill_dress);
88 return g_test_run();