[adg/tests] Added test-table
[adg.git] / adg / tests / test-table.c
blob902b72161c461bb7104f658c4589e141469e1b86
1 /* ADG - Automatic Drawing Generation
2 * Copyright (C) 2010 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 _adg_test_table_dress(void) { AdgTable *table;
25 AdgDress valid_dress, incompatible_dress;
26 AdgDress table_dress;
28 table = adg_table_new();
29 valid_dress = ADG_DRESS_TABLE;
30 incompatible_dress = ADG_DRESS_LINE;
32 /* Using the public APIs */
33 adg_table_set_table_dress(table, valid_dress);
34 table_dress = adg_table_get_table_dress(table);
35 g_assert_cmpint(table_dress, ==, valid_dress);
37 adg_table_set_table_dress(table, incompatible_dress);
38 table_dress = adg_table_get_table_dress(table);
39 g_assert_cmpint(table_dress, ==, valid_dress);
41 /* Using GObject property methods */
42 g_object_set(table, "table-dress", valid_dress, NULL);
43 g_object_get(table, "table-dress", &table_dress, NULL);
44 g_assert_cmpint(table_dress, ==, valid_dress);
46 g_object_set(table, "table-dress", incompatible_dress, NULL);
47 g_object_get(table, "table-dress", &table_dress, NULL);
48 g_assert_cmpint(table_dress, ==, valid_dress);
50 g_object_unref(table);
53 static void
54 _adg_test_has_frame(void)
56 AdgTable *table;
57 gboolean invalid_boolean;
58 gboolean has_frame;
60 table = adg_table_new();
61 invalid_boolean = (gboolean) 1234;
63 /* Using the public APIs */
64 adg_table_switch_frame(table, FALSE);
65 has_frame = adg_table_has_frame(table);
66 g_assert(!has_frame);
68 adg_table_switch_frame(table, invalid_boolean);
69 has_frame = adg_table_has_frame(table);
70 g_assert(!has_frame);
72 adg_table_switch_frame(table, TRUE);
73 has_frame = adg_table_has_frame(table);
74 g_assert(has_frame);
76 /* Using GObject property methods */
77 g_object_set(table, "has-frame", FALSE, NULL);
78 g_object_get(table, "has-frame", &has_frame, NULL);
79 g_assert(!has_frame);
81 g_object_set(table, "has-frame", invalid_boolean, NULL);
82 g_object_get(table, "has-frame", &has_frame, NULL);
83 g_assert(!has_frame);
85 g_object_set(table, "has-frame", TRUE, NULL);
86 g_object_get(table, "has-frame", &has_frame, NULL);
87 g_assert(has_frame);
89 g_object_unref(table);
93 int
94 main(int argc, char *argv[])
96 adg_test_init(&argc, &argv);
98 adg_test_add_func("/adg/table/table-dress", _adg_test_table_dress);
99 adg_test_add_func("/adg/table/has_frame", _adg_test_has_frame);
101 return g_test_run();