AdgEntity: added "destroy" signal
[adg.git] / src / adg / tests / test-arrow.c
blobf84bee920cfa4ecb2e7c8fe6b3fc63c86e93acb0
1 /* ADG - Automatic Drawing Generation
2 * Copyright (C) 2010,2011 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_angle(void)
27 AdgArrow *arrow;
28 gdouble valid_value, invalid_value;
29 gdouble angle;
31 arrow = adg_arrow_new();
32 valid_value = -G_PI_2;
33 invalid_value = G_PI + 1;
35 /* Using the public APIs */
36 adg_arrow_set_angle(arrow, valid_value);
37 angle = adg_arrow_get_angle(arrow);
38 g_assert_cmpfloat(angle, ==, valid_value);
40 adg_arrow_set_angle(arrow, -G_PI);
41 angle = adg_arrow_get_angle(arrow);
42 g_assert_cmpfloat(angle, ==, G_PI);
44 adg_arrow_set_angle(arrow, invalid_value);
45 angle = adg_arrow_get_angle(arrow);
46 g_assert_cmpfloat(angle, !=, invalid_value);
48 /* Using GObject property methods */
49 g_object_set(arrow, "angle", valid_value, NULL);
50 g_object_get(arrow, "angle", &angle, NULL);
51 g_assert_cmpfloat(angle, ==, valid_value);
53 g_object_set(arrow, "angle", -G_PI, NULL);
54 g_object_get(arrow, "angle", &angle, NULL);
55 g_assert_cmpfloat(angle, ==, G_PI);
57 g_object_set(arrow, "angle", invalid_value, NULL);
58 g_object_get(arrow, "angle", &angle, NULL);
59 g_assert_cmpfloat(angle, !=, invalid_value);
61 adg_entity_destroy(ADG_ENTITY(arrow));
65 int
66 main(int argc, char *argv[])
68 adg_test_init(&argc, &argv);
70 adg_test_add_func("/adg/arrow/angle", _adg_test_angle);
72 return g_test_run();