[AdgFontStyle] Returning AdgFontStyle * from constructors
[adg.git] / adg / tests / test-container.c
blob8049540f28d8b2be43f613195d21c5da844f878b
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
25 _adg_container_child(void)
27 AdgContainer *container;
28 AdgEntity *valid_entity, *invalid_entity;
29 GSList *children;
31 container = adg_container_new();
32 valid_entity = ADG_ENTITY(adg_logo_new());
33 invalid_entity = adg_test_invalid_pointer();
35 /* Keep alive the entity between all the tests */
36 g_object_ref(valid_entity);
38 /* Using the public APIs */
39 adg_container_add(container, NULL);
40 children = adg_container_children(container);
41 g_assert(children == NULL);
43 adg_container_add(container, invalid_entity);
44 children = adg_container_children(container);
45 g_assert(children == NULL);
47 adg_container_add(container, valid_entity);
48 children = adg_container_children(container);
49 g_assert(children != NULL);
50 g_assert(children->data == valid_entity);
51 g_slist_free(children);
53 adg_container_remove(container, invalid_entity);
54 children = adg_container_children(container);
55 g_assert(children != NULL);
56 g_assert(children->data == valid_entity);
57 g_slist_free(children);
59 adg_container_remove(container, valid_entity);
60 children = adg_container_children(container);
61 g_assert(children == NULL);
63 /* Using GObject property methods */
64 g_object_set(container, "child", NULL, NULL);
65 children = adg_container_children(container);
66 g_assert(children == NULL);
68 g_object_set(container, "child", invalid_entity, NULL);
69 children = adg_container_children(container);
70 g_assert(children == NULL);
72 g_object_set(container, "child", valid_entity, NULL);
73 children = adg_container_children(container);
74 g_assert(children != NULL);
75 g_assert(children->data == valid_entity);
76 g_slist_free(children);
78 adg_container_remove(container, valid_entity);
79 children = adg_container_children(container);
80 g_assert(children == NULL);
82 g_object_unref(container);
83 g_object_unref(valid_entity);
87 int
88 main(int argc, char *argv[])
90 adg_test_init(&argc, &argv);
92 adg_test_add_func("/adg/container/child", _adg_container_child);
94 return g_test_run();