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"
29 const AdgPair
*got_pair
;
32 model
= ADG_MODEL(adg_path_new());
36 adg_model_set_named_pair(model
, "Existent", &pair
);
37 got_pair
= adg_model_get_named_pair(model
, "Existent");
38 g_assert_cmpint(pair
.x
, ==, got_pair
->x
);
39 g_assert_cmpint(pair
.y
, ==, got_pair
->y
);
41 got_pair
= adg_model_get_named_pair(model
, "Not existent");
42 g_assert(got_pair
== NULL
);
44 adg_model_set_named_pair(model
, "Latin1: àèìòù", &pair
);
45 got_pair
= adg_model_get_named_pair(model
, "Latin1: àèìòù");
46 g_assert_cmpint(pair
.x
, ==, got_pair
->x
);
47 g_assert_cmpint(pair
.y
, ==, got_pair
->y
);
49 g_object_unref(model
);
57 const GSList
*dependencies
;
60 model
= ADG_MODEL(adg_path_new());
61 entity
= ADG_ENTITY(adg_logo_new());
63 g_object_set(model
, "dependency", NULL
, NULL
);
64 dependencies
= adg_model_get_dependencies(model
);
65 g_assert(dependencies
== NULL
);
67 adg_model_add_dependency(model
, NULL
);
68 dependencies
= adg_model_get_dependencies(model
);
69 g_assert(dependencies
== NULL
);
71 adg_model_add_dependency(model
, entity
);
72 dependencies
= adg_model_get_dependencies(model
);
73 g_assert(dependencies
!= NULL
);
74 g_assert(dependencies
->data
== entity
);
76 adg_model_remove_dependency(model
, entity
);
77 dependencies
= adg_model_get_dependencies(model
);
78 g_assert(dependencies
== NULL
);
80 g_object_unref(model
);
81 g_object_unref(entity
);
86 main(int argc
, char *argv
[])
88 test_init(&argc
, &argv
);
90 g_test_add_func("/adg/model/named-pair", test_named_pair
);
91 g_test_add_func("/adg/model/dependency", test_dependency
);