build: depends on cairo-gobject if introspection is enabled
[adg.git] / src / adg / tests / test-alignment.c
bloba77fcba2c0b336e874a0e209d20cba3f8b166029
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"
24 static void
25 _adg_alignment_factor(void)
27 AdgAlignment *alignment;
28 CpmlPair null_factor, identity_factor;
29 const CpmlPair *factor;
30 CpmlPair *factor_dup;
32 alignment = adg_alignment_new(NULL);
33 null_factor.x = 0;
34 null_factor.y = 0;
35 identity_factor.x = 1;
36 identity_factor.y = 1;
38 /* By default, the alignment should be initialized with a null factor */
39 factor = adg_alignment_get_factor(alignment);
40 g_assert(cpml_pair_equal(factor, &null_factor));
42 /* Using the public APIs */
43 adg_alignment_set_factor(alignment, &identity_factor);
44 factor = adg_alignment_get_factor(alignment);
45 g_assert(cpml_pair_equal(factor, &identity_factor));
47 adg_alignment_set_factor_explicit(alignment, 0, 0);
48 factor = adg_alignment_get_factor(alignment);
49 g_assert(cpml_pair_equal(factor, &null_factor));
51 adg_alignment_set_factor(alignment, NULL);
52 factor = adg_alignment_get_factor(alignment);
53 g_assert(cpml_pair_equal(factor, &null_factor));
55 /* Using GObject property methods */
56 g_object_set(alignment, "factor", &identity_factor, NULL);
57 g_object_get(alignment, "factor", &factor_dup, NULL);
58 g_assert(cpml_pair_equal(factor_dup, &identity_factor));
59 g_free(factor_dup);
61 g_object_set(alignment, "factor", NULL, NULL);
62 g_object_get(alignment, "factor", &factor_dup, NULL);
63 g_assert(cpml_pair_equal(factor_dup, &identity_factor));
64 g_free(factor_dup);
66 g_object_set(alignment, "factor", &null_factor, NULL);
67 g_object_get(alignment, "factor", &factor_dup, NULL);
68 g_assert(cpml_pair_equal(factor_dup, &null_factor));
69 g_free(factor_dup);
71 g_object_unref(alignment);
75 int
76 main(int argc, char *argv[])
78 adg_test_init(&argc, &argv);
80 adg_test_add_func("/adg/alignment/factor", _adg_alignment_factor);
82 return g_test_run();