doc: update copyright line for 2021
[adg.git] / src / adg / tests / test-table.c
blobb26ae5bd836843afcc1b73635d07dae95d4fb9b9
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_local_mix(void)
28 AdgTable *table;
29 AdgEntity *entity;
31 /* Check default local mix method */
32 table = adg_table_new();
33 entity = (AdgEntity *) table;
34 g_assert_cmpint(adg_entity_get_local_mix(entity), ==, ADG_MIX_DISABLED);
35 adg_entity_destroy(entity);
37 /* Check local mix method overriding */
38 table = g_object_new(ADG_TYPE_TABLE, "local-mix", ADG_MIX_ANCESTORS_NORMALIZED, NULL);
39 entity = (AdgEntity *) table;
40 g_assert_cmpint(adg_entity_get_local_mix(entity), ==, ADG_MIX_ANCESTORS_NORMALIZED);
41 adg_entity_destroy(entity);
43 /* Check default mix using GObject methods */
44 table = g_object_new(ADG_TYPE_TABLE, NULL);
45 entity = (AdgEntity *) table;
46 g_assert_cmpint(adg_entity_get_local_mix(entity), ==, ADG_MIX_DISABLED);
47 adg_entity_destroy(entity);
50 static void
51 _adg_property_table_dress(void)
53 AdgTable *table;
54 AdgDress valid_dress, incompatible_dress;
55 AdgDress table_dress;
57 table = adg_table_new();
58 valid_dress = ADG_DRESS_TABLE;
59 incompatible_dress = ADG_DRESS_LINE;
61 /* Using the public APIs */
62 adg_table_set_table_dress(table, valid_dress);
63 table_dress = adg_table_get_table_dress(table);
64 g_assert_cmpint(table_dress, ==, valid_dress);
66 adg_table_set_table_dress(table, incompatible_dress);
67 table_dress = adg_table_get_table_dress(table);
68 g_assert_cmpint(table_dress, ==, valid_dress);
70 /* Using GObject property methods */
71 g_object_set(table, "table-dress", valid_dress, NULL);
72 g_object_get(table, "table-dress", &table_dress, NULL);
73 g_assert_cmpint(table_dress, ==, valid_dress);
75 g_object_set(table, "table-dress", incompatible_dress, NULL);
76 g_object_get(table, "table-dress", &table_dress, NULL);
77 g_assert_cmpint(table_dress, ==, valid_dress);
79 adg_entity_destroy(ADG_ENTITY(table));
82 static void
83 _adg_property_has_frame(void)
85 AdgTable *table;
86 gboolean invalid_boolean;
87 gboolean has_frame;
89 table = adg_table_new();
90 invalid_boolean = (gboolean) 1234;
92 /* Using the public APIs */
93 adg_table_switch_frame(table, FALSE);
94 has_frame = adg_table_has_frame(table);
95 g_assert_false(has_frame);
97 adg_table_switch_frame(table, invalid_boolean);
98 has_frame = adg_table_has_frame(table);
99 g_assert_false(has_frame);
101 adg_table_switch_frame(table, TRUE);
102 has_frame = adg_table_has_frame(table);
103 g_assert_true(has_frame);
105 /* Using GObject property methods */
106 g_object_set(table, "has-frame", FALSE, NULL);
107 g_object_get(table, "has-frame", &has_frame, NULL);
108 g_assert_false(has_frame);
110 g_object_set(table, "has-frame", invalid_boolean, NULL);
111 g_object_get(table, "has-frame", &has_frame, NULL);
112 g_assert_false(has_frame);
114 g_object_set(table, "has-frame", TRUE, NULL);
115 g_object_get(table, "has-frame", &has_frame, NULL);
116 g_assert_true(has_frame);
118 adg_entity_destroy(ADG_ENTITY(table));
123 main(int argc, char *argv[])
125 adg_test_init(&argc, &argv);
127 adg_test_add_object_checks("/adg/table/type/object", ADG_TYPE_TABLE);
128 adg_test_add_entity_checks("/adg/table/type/entity", ADG_TYPE_TABLE);
130 g_test_add_func("/adg/table/property/local-mix", _adg_property_local_mix);
131 g_test_add_func("/adg/table/property/table-dress", _adg_property_table_dress);
132 g_test_add_func("/adg/table/property/has-frame", _adg_property_has_frame);
134 return g_test_run();