1 /* ADG - Automatic Drawing Generation
2 * Copyright (C) 2007-2021 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.
26 _adg_behavior_misc(void)
28 GParamSpec
*param
= g_param_spec_internal(ADG_TYPE_PARAM_DRESS
,
29 "name", "nick", "blurb",
32 g_param_spec_ref_sink(param
);
34 g_assert_true(G_IS_PARAM_SPEC(param
));
35 g_assert_true(ADG_IS_PARAM_DRESS(param
));
37 g_param_spec_unref(param
);
41 _adg_method_set_default(void)
43 GParamSpec
*param
= g_param_spec_internal(ADG_TYPE_PARAM_DRESS
,
44 "param", "nick", "blurb",
48 g_param_spec_ref_sink(param
);
50 g_value_init(&value
, ADG_TYPE_DRESS
);
51 g_assert_true(ADG_VALUE_HOLDS_DRESS(&value
));
52 g_assert_cmpint(g_value_get_enum(&value
), ==, ADG_DRESS_UNDEFINED
);
54 g_value_set_enum(&value
, ADG_DRESS_TABLE
);
55 g_assert_cmpint(g_value_get_enum(&value
), ==, ADG_DRESS_TABLE
);
57 g_param_value_set_default(param
, &value
);
58 g_assert_cmpint(g_value_get_enum(&value
), ==, ADG_DRESS_UNDEFINED
);
60 g_param_spec_unref(param
);
64 _adg_method_values_cmp(void)
66 GParamSpec
*param
= g_param_spec_internal(ADG_TYPE_PARAM_DRESS
,
67 "param", "nick", "blurb",
69 GValue value1
= { 0 }, value2
= { 0 };
71 g_param_spec_ref_sink(param
);
73 g_value_init(&value1
, ADG_TYPE_DRESS
);
74 g_value_init(&value2
, ADG_TYPE_DRESS
);
76 g_value_set_enum(&value1
, ADG_DRESS_FONT
);
77 g_value_set_enum(&value2
, ADG_DRESS_FONT
);
79 g_assert_cmpint(g_param_values_cmp(param
, &value1
, &value2
), ==, 0);
81 g_value_set_enum(&value2
, ADG_DRESS_TABLE
);
82 g_assert_cmpint(g_param_values_cmp(param
, &value1
, &value2
), ==, -1);
83 g_assert_cmpint(g_param_values_cmp(param
, &value2
, &value1
), ==, +1);
85 g_value_set_enum(&value1
, ADG_DRESS_TABLE
);
86 g_assert_cmpint(g_param_values_cmp(param
, &value1
, &value2
), ==, 0);
88 g_param_spec_unref(param
);
93 main(int argc
, char *argv
[])
95 adg_test_init(&argc
, &argv
);
97 g_test_add_func("/adg/param-dress/behavior/misc", _adg_behavior_misc
);
99 g_test_add_func("/adg/param-dress/method/set-default", _adg_method_set_default
);
100 g_test_add_func("/adg/param-dress/method/values-cmp", _adg_method_values_cmp
);