adg: properly initialize AdgTable:local-mix
[adg.git] / src / adg / tests / test-table.c
blobcb37c206d42c66f6308dd8340cf4788ade6238a4
1 /* ADG - Automatic Drawing Generation
2 * Copyright (C) 2007,2008,2009,2010,2011,2012,2013 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 "test-internal.h"
24 static void
25 _adg_test_local_mix(void)
27 AdgTable *table;
28 AdgEntity *entity;
30 /* Check default local mix method */
31 table = adg_table_new();
32 entity = (AdgEntity *) table;
33 g_assert_cmpint(adg_entity_get_local_mix(entity), ==, ADG_MIX_DISABLED);
34 adg_entity_destroy(entity);
36 /* Check local mix method overriding */
37 table = g_object_new(ADG_TYPE_TABLE, "local-mix", ADG_MIX_ANCESTORS_NORMALIZED, NULL);
38 entity = (AdgEntity *) table;
39 g_assert_cmpint(adg_entity_get_local_mix(entity), ==, ADG_MIX_ANCESTORS_NORMALIZED);
40 adg_entity_destroy(entity);
42 /* Check default mix using GObject methods */
43 table = g_object_new(ADG_TYPE_TABLE, NULL);
44 entity = (AdgEntity *) table;
45 g_assert_cmpint(adg_entity_get_local_mix(entity), ==, ADG_MIX_DISABLED);
46 adg_entity_destroy(entity);
49 static void
50 _adg_test_table_dress(void)
52 AdgTable *table;
53 AdgDress valid_dress, incompatible_dress;
54 AdgDress table_dress;
56 table = adg_table_new();
57 valid_dress = ADG_DRESS_TABLE;
58 incompatible_dress = ADG_DRESS_LINE;
60 /* Using the public APIs */
61 adg_table_set_table_dress(table, valid_dress);
62 table_dress = adg_table_get_table_dress(table);
63 g_assert_cmpint(table_dress, ==, valid_dress);
65 adg_table_set_table_dress(table, incompatible_dress);
66 table_dress = adg_table_get_table_dress(table);
67 g_assert_cmpint(table_dress, ==, valid_dress);
69 /* Using GObject property methods */
70 g_object_set(table, "table-dress", valid_dress, NULL);
71 g_object_get(table, "table-dress", &table_dress, NULL);
72 g_assert_cmpint(table_dress, ==, valid_dress);
74 g_object_set(table, "table-dress", incompatible_dress, NULL);
75 g_object_get(table, "table-dress", &table_dress, NULL);
76 g_assert_cmpint(table_dress, ==, valid_dress);
78 adg_entity_destroy(ADG_ENTITY(table));
81 static void
82 _adg_test_has_frame(void)
84 AdgTable *table;
85 gboolean invalid_boolean;
86 gboolean has_frame;
88 table = adg_table_new();
89 invalid_boolean = (gboolean) 1234;
91 /* Using the public APIs */
92 adg_table_switch_frame(table, FALSE);
93 has_frame = adg_table_has_frame(table);
94 g_assert(!has_frame);
96 adg_table_switch_frame(table, invalid_boolean);
97 has_frame = adg_table_has_frame(table);
98 g_assert(!has_frame);
100 adg_table_switch_frame(table, TRUE);
101 has_frame = adg_table_has_frame(table);
102 g_assert(has_frame);
104 /* Using GObject property methods */
105 g_object_set(table, "has-frame", FALSE, NULL);
106 g_object_get(table, "has-frame", &has_frame, NULL);
107 g_assert(!has_frame);
109 g_object_set(table, "has-frame", invalid_boolean, NULL);
110 g_object_get(table, "has-frame", &has_frame, NULL);
111 g_assert(!has_frame);
113 g_object_set(table, "has-frame", TRUE, NULL);
114 g_object_get(table, "has-frame", &has_frame, NULL);
115 g_assert(has_frame);
117 adg_entity_destroy(ADG_ENTITY(table));
122 main(int argc, char *argv[])
124 adg_test_init(&argc, &argv);
126 adg_test_add_func("/adg/table/local-mix", _adg_test_local_mix);
127 adg_test_add_func("/adg/table/table-dress", _adg_test_table_dress);
128 adg_test_add_func("/adg/table/has-frame", _adg_test_has_frame);
130 return g_test_run();