1 /* ADG - Automatic Drawing Generation
2 * Copyright (C) 2010,2011,2012 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_alignment_factor(void)
27 AdgAlignment
*alignment
;
28 CpmlPair null_factor
, identity_factor
;
29 const CpmlPair
*factor
;
32 alignment
= adg_alignment_new(NULL
);
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
));
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
));
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
));
71 g_object_unref(alignment
);
76 main(int argc
, char *argv
[])
78 adg_test_init(&argc
, &argv
);
80 adg_test_add_func("/adg/alignment/factor", _adg_alignment_factor
);