[build] Let "make distcheck" work again
[adg.git] / adg / tests / test-edges.c
blob22e2fd801f493234096bfb5c7660aaa21da9d0e1
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_test_source(void)
27 AdgEdges *edges;
28 AdgTrail *valid_trail, *invalid_trail;
29 AdgTrail *source;
31 edges = adg_edges_new();
32 valid_trail = ADG_TRAIL(adg_path_new());
33 invalid_trail = adg_test_invalid_pointer();
35 /* Using the public APIs */
36 adg_edges_set_source(edges, valid_trail);
37 source = adg_edges_get_source(edges);
38 g_assert(source == valid_trail);
40 adg_edges_set_source(edges, invalid_trail);
41 source = adg_edges_get_source(edges);
42 g_assert(source == valid_trail);
44 adg_edges_set_source(edges, NULL);
45 source = adg_edges_get_source(edges);
46 g_assert(source == NULL);
48 /* Using GObject property methods */
49 g_object_set(edges, "source", valid_trail, NULL);
50 g_object_get(edges, "source", &source, NULL);
51 g_assert(source == valid_trail);
52 g_object_unref(source);
54 g_object_set(edges, "source", invalid_trail, NULL);
55 g_object_get(edges, "source", &source, NULL);
56 g_assert(source == valid_trail);
57 g_object_unref(source);
59 g_object_set(edges, "source", NULL, NULL);
60 g_object_get(edges, "source", &source, NULL);
61 g_assert(source == NULL);
63 g_object_unref(edges);
64 g_object_unref(valid_trail);
67 static void
68 _adg_test_critical_angle(void)
70 AdgEdges *edges;
71 gdouble valid_value, invalid_value;
72 gdouble critical_angle;
74 edges = adg_edges_new();
75 valid_value = G_PI / 10;
76 invalid_value = G_PI + 1;
78 /* Using the public APIs */
79 adg_edges_set_critical_angle(edges, valid_value);
80 critical_angle = adg_edges_get_critical_angle(edges);
81 g_assert_cmpfloat(critical_angle, ==, valid_value);
83 adg_edges_set_critical_angle(edges, invalid_value);
84 critical_angle = adg_edges_get_critical_angle(edges);
85 g_assert_cmpfloat(critical_angle, !=, invalid_value);
87 /* Using GObject property methods */
88 g_object_set(edges, "critical-angle", valid_value, NULL);
89 g_object_get(edges, "critical-angle", &critical_angle, NULL);
90 g_assert_cmpfloat(critical_angle, ==, valid_value);
92 g_object_set(edges, "critical-angle", invalid_value, NULL);
93 g_object_get(edges, "critical-angle", &critical_angle, NULL);
94 g_assert_cmpfloat(critical_angle, !=, invalid_value);
96 g_object_unref(edges);
101 main(int argc, char *argv[])
103 adg_test_init(&argc, &argv);
105 adg_test_add_func("/adg/edges/source", _adg_test_source);
106 adg_test_add_func("/adg/edges/critical-angle", _adg_test_critical_angle);
108 return g_test_run();