1 /* ADG - Automatic Drawing Generation
2 * Copyright (C) 2007,2008,2009,2010,2011,2012,2013 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"
25 _adg_path_callback(AdgTrail
*trail
, gpointer user_data
)
27 static cairo_path_data_t data
[] = {
28 { .header
= { CPML_MOVE
, 2 }},
30 { .header
= { CPML_LINE
, 2 }},
32 { .header
= { CPML_LINE
, 2 }},
35 static cairo_path_t path
= {
46 _adg_test_max_angle(void)
49 gdouble valid_value
, invalid_value
;
52 trail
= adg_trail_new(_adg_path_callback
, NULL
);
53 valid_value
= G_PI
/ 10;
54 invalid_value
= G_PI
+ 1;
56 /* Using the public APIs */
57 adg_trail_set_max_angle(trail
, valid_value
);
58 max_angle
= adg_trail_get_max_angle(trail
);
59 g_assert_cmpfloat(max_angle
, ==, valid_value
);
61 adg_trail_set_max_angle(trail
, invalid_value
);
62 max_angle
= adg_trail_get_max_angle(trail
);
63 g_assert_cmpfloat(max_angle
, !=, invalid_value
);
65 /* Using GObject property methods */
66 g_object_set(trail
, "max-angle", valid_value
, NULL
);
67 g_object_get(trail
, "max-angle", &max_angle
, NULL
);
68 g_assert_cmpfloat(max_angle
, ==, valid_value
);
70 g_object_set(trail
, "max-angle", invalid_value
, NULL
);
71 g_object_get(trail
, "max-angle", &max_angle
, NULL
);
72 g_assert_cmpfloat(max_angle
, !=, invalid_value
);
74 g_object_unref(trail
);
79 main(int argc
, char *argv
[])
81 adg_test_init(&argc
, &argv
);
83 adg_test_add_func("/adg/trail/max-angle", _adg_test_max_angle
);