1 /* testcomparable.c generated by valac 0.19.0.4-d6d4, the Vala compiler
2 * generated from testcomparable.vala, do not modify */
3
4 /* testcomparable.vala
5 *
6 * Copyright (C) 2009 Didier Villevalois
7 *
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
12
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
17
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 *
22 * Author:
23 * Didier 'Ptitjes' Villevalois <ptitjes@free.fr>
24 */
25
26 #include <glib.h>
27 #include <glib-object.h>
28 #include <stdlib.h>
29 #include <string.h>
30 #include <gee.h>
31
32
33 #define GEE_TYPE_TEST_CASE (gee_test_case_get_type ())
34 #define GEE_TEST_CASE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GEE_TYPE_TEST_CASE, GeeTestCase))
35 #define GEE_TEST_CASE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GEE_TYPE_TEST_CASE, GeeTestCaseClass))
36 #define GEE_IS_TEST_CASE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GEE_TYPE_TEST_CASE))
37 #define GEE_IS_TEST_CASE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GEE_TYPE_TEST_CASE))
38 #define GEE_TEST_CASE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GEE_TYPE_TEST_CASE, GeeTestCaseClass))
39
40 typedef struct _GeeTestCase GeeTestCase;
41 typedef struct _GeeTestCaseClass GeeTestCaseClass;
42 typedef struct _GeeTestCasePrivate GeeTestCasePrivate;
43
44 #define TYPE_COMPARABLE_TESTS (comparable_tests_get_type ())
45 #define COMPARABLE_TESTS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_COMPARABLE_TESTS, ComparableTests))
46 #define COMPARABLE_TESTS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_COMPARABLE_TESTS, ComparableTestsClass))
47 #define IS_COMPARABLE_TESTS(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_COMPARABLE_TESTS))
48 #define IS_COMPARABLE_TESTS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_COMPARABLE_TESTS))
49 #define COMPARABLE_TESTS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_COMPARABLE_TESTS, ComparableTestsClass))
50
51 typedef struct _ComparableTests ComparableTests;
52 typedef struct _ComparableTestsClass ComparableTestsClass;
53 typedef struct _ComparableTestsPrivate ComparableTestsPrivate;
54
55 #define COMPARABLE_TESTS_TYPE_TEST_COMPARABLE (comparable_tests_test_comparable_get_type ())
56 #define COMPARABLE_TESTS_TEST_COMPARABLE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), COMPARABLE_TESTS_TYPE_TEST_COMPARABLE, ComparableTestsTestComparable))
57 #define COMPARABLE_TESTS_TEST_COMPARABLE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), COMPARABLE_TESTS_TYPE_TEST_COMPARABLE, ComparableTestsTestComparableClass))
58 #define COMPARABLE_TESTS_IS_TEST_COMPARABLE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), COMPARABLE_TESTS_TYPE_TEST_COMPARABLE))
59 #define COMPARABLE_TESTS_IS_TEST_COMPARABLE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), COMPARABLE_TESTS_TYPE_TEST_COMPARABLE))
60 #define COMPARABLE_TESTS_TEST_COMPARABLE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), COMPARABLE_TESTS_TYPE_TEST_COMPARABLE, ComparableTestsTestComparableClass))
61
62 typedef struct _ComparableTestsTestComparable ComparableTestsTestComparable;
63 typedef struct _ComparableTestsTestComparableClass ComparableTestsTestComparableClass;
64 typedef struct _ComparableTestsTestComparablePrivate ComparableTestsTestComparablePrivate;
65 #define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
66 #define _vala_assert(expr, msg) if G_LIKELY (expr) ; else g_assertion_message_expr (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, msg);
67
68 struct _GeeTestCase {
69 GObject parent_instance;
70 GeeTestCasePrivate * priv;
71 };
72
73 struct _GeeTestCaseClass {
74 GObjectClass parent_class;
75 void (*set_up) (GeeTestCase* self);
76 void (*tear_down) (GeeTestCase* self);
77 };
78
79 struct _ComparableTests {
80 GeeTestCase parent_instance;
81 ComparableTestsPrivate * priv;
82 };
83
84 struct _ComparableTestsClass {
85 GeeTestCaseClass parent_class;
86 };
87
88 typedef void (*GeeTestCaseTestMethod) (void* user_data);
89 struct _ComparableTestsTestComparable {
90 GObject parent_instance;
91 ComparableTestsTestComparablePrivate * priv;
92 gint _a;
93 };
94
95 struct _ComparableTestsTestComparableClass {
96 GObjectClass parent_class;
97 };
98
99
100 static gpointer comparable_tests_parent_class = NULL;
101 static gpointer comparable_tests_test_comparable_parent_class = NULL;
102 static GeeComparableIface* comparable_tests_test_comparable_gee_comparable_parent_iface = NULL;
103
104 GType gee_test_case_get_type (void) G_GNUC_CONST;
105 GType comparable_tests_get_type (void) G_GNUC_CONST;
106 enum {
107 COMPARABLE_TESTS_DUMMY_PROPERTY
108 };
109 ComparableTests* comparable_tests_new (void);
110 ComparableTests* comparable_tests_construct (GType object_type);
111 GeeTestCase* gee_test_case_construct (GType object_type, const gchar* name);
112 void gee_test_case_add_test (GeeTestCase* self, const gchar* name, GeeTestCaseTestMethod test, void* test_target);
113 void comparable_tests_test_selected_functions (ComparableTests* self);
114 static void _comparable_tests_test_selected_functions_gee_test_case_test_method (gpointer self);
115 static ComparableTestsTestComparable* comparable_tests_test_comparable_new (gint a);
116 static ComparableTestsTestComparable* comparable_tests_test_comparable_construct (GType object_type, gint a);
117 static GType comparable_tests_test_comparable_get_type (void) G_GNUC_CONST G_GNUC_UNUSED;
118 enum {
119 COMPARABLE_TESTS_TEST_COMPARABLE_DUMMY_PROPERTY
120 };
121 static gint comparable_tests_test_comparable_real_compare_to (GeeComparable* base, ComparableTestsTestComparable* object);
122 static void comparable_tests_test_comparable_finalize (GObject* obj);
123
124
_comparable_tests_test_selected_functions_gee_test_case_test_method(gpointer self)125 static void _comparable_tests_test_selected_functions_gee_test_case_test_method (gpointer self) {
126 comparable_tests_test_selected_functions (self);
127 }
128
129
comparable_tests_construct(GType object_type)130 ComparableTests* comparable_tests_construct (GType object_type) {
131 ComparableTests * self = NULL;
132 self = (ComparableTests*) gee_test_case_construct (object_type, "Comparable");
133 gee_test_case_add_test ((GeeTestCase*) self, "[Comparable] selected functions", _comparable_tests_test_selected_functions_gee_test_case_test_method, self);
134 return self;
135 }
136
137
comparable_tests_new(void)138 ComparableTests* comparable_tests_new (void) {
139 return comparable_tests_construct (TYPE_COMPARABLE_TESTS);
140 }
141
142
comparable_tests_test_selected_functions(ComparableTests * self)143 void comparable_tests_test_selected_functions (ComparableTests* self) {
144 ComparableTestsTestComparable* _tmp0_;
145 ComparableTestsTestComparable* o1;
146 ComparableTestsTestComparable* _tmp1_;
147 ComparableTestsTestComparable* o2;
148 GCompareFunc _tmp2_ = NULL;
149 GCompareFunc compare;
150 gint _tmp3_ = 0;
151 gint _tmp4_ = 0;
152 g_return_if_fail (self != NULL);
153 _tmp0_ = comparable_tests_test_comparable_new (10);
154 o1 = _tmp0_;
155 _tmp1_ = comparable_tests_test_comparable_new (20);
156 o2 = _tmp1_;
157 _tmp2_ = gee_functions_get_compare_func_for (COMPARABLE_TESTS_TYPE_TEST_COMPARABLE);
158 compare = _tmp2_;
159 _tmp3_ = compare (o1, o2);
160 _vala_assert (_tmp3_ < 0, "compare (o1, o2) < 0");
161 o1->_a = 42;
162 _tmp4_ = compare (o1, o2);
163 _vala_assert (_tmp4_ > 0, "compare (o1, o2) > 0");
164 _g_object_unref0 (o2);
165 _g_object_unref0 (o1);
166 }
167
168
comparable_tests_test_comparable_construct(GType object_type,gint a)169 static ComparableTestsTestComparable* comparable_tests_test_comparable_construct (GType object_type, gint a) {
170 ComparableTestsTestComparable * self = NULL;
171 gint _tmp0_;
172 self = (ComparableTestsTestComparable*) g_object_new (object_type, NULL);
173 _tmp0_ = a;
174 self->_a = _tmp0_;
175 return self;
176 }
177
178
comparable_tests_test_comparable_new(gint a)179 static ComparableTestsTestComparable* comparable_tests_test_comparable_new (gint a) {
180 return comparable_tests_test_comparable_construct (COMPARABLE_TESTS_TYPE_TEST_COMPARABLE, a);
181 }
182
183
comparable_tests_test_comparable_real_compare_to(GeeComparable * base,ComparableTestsTestComparable * object)184 static gint comparable_tests_test_comparable_real_compare_to (GeeComparable* base, ComparableTestsTestComparable* object) {
185 ComparableTestsTestComparable * self;
186 gint result = 0;
187 gint _tmp0_;
188 ComparableTestsTestComparable* _tmp1_;
189 gint _tmp2_;
190 self = (ComparableTestsTestComparable*) base;
191 g_return_val_if_fail (object != NULL, 0);
192 _tmp0_ = self->_a;
193 _tmp1_ = object;
194 _tmp2_ = _tmp1_->_a;
195 result = _tmp0_ - _tmp2_;
196 return result;
197 }
198
199
comparable_tests_test_comparable_class_init(ComparableTestsTestComparableClass * klass)200 static void comparable_tests_test_comparable_class_init (ComparableTestsTestComparableClass * klass) {
201 comparable_tests_test_comparable_parent_class = g_type_class_peek_parent (klass);
202 G_OBJECT_CLASS (klass)->finalize = comparable_tests_test_comparable_finalize;
203 }
204
205
comparable_tests_test_comparable_gee_comparable_interface_init(GeeComparableIface * iface)206 static void comparable_tests_test_comparable_gee_comparable_interface_init (GeeComparableIface * iface) {
207 comparable_tests_test_comparable_gee_comparable_parent_iface = g_type_interface_peek_parent (iface);
208 iface->compare_to = (gint (*)(GeeComparable*, gconstpointer)) comparable_tests_test_comparable_real_compare_to;
209 }
210
211
comparable_tests_test_comparable_instance_init(ComparableTestsTestComparable * self)212 static void comparable_tests_test_comparable_instance_init (ComparableTestsTestComparable * self) {
213 }
214
215
comparable_tests_test_comparable_finalize(GObject * obj)216 static void comparable_tests_test_comparable_finalize (GObject* obj) {
217 ComparableTestsTestComparable * self;
218 self = G_TYPE_CHECK_INSTANCE_CAST (obj, COMPARABLE_TESTS_TYPE_TEST_COMPARABLE, ComparableTestsTestComparable);
219 G_OBJECT_CLASS (comparable_tests_test_comparable_parent_class)->finalize (obj);
220 }
221
222
comparable_tests_test_comparable_get_type(void)223 static GType comparable_tests_test_comparable_get_type (void) {
224 static volatile gsize comparable_tests_test_comparable_type_id__volatile = 0;
225 if (g_once_init_enter (&comparable_tests_test_comparable_type_id__volatile)) {
226 static const GTypeInfo g_define_type_info = { sizeof (ComparableTestsTestComparableClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) comparable_tests_test_comparable_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (ComparableTestsTestComparable), 0, (GInstanceInitFunc) comparable_tests_test_comparable_instance_init, NULL };
227 static const GInterfaceInfo gee_comparable_info = { (GInterfaceInitFunc) comparable_tests_test_comparable_gee_comparable_interface_init, (GInterfaceFinalizeFunc) NULL, NULL};
228 GType comparable_tests_test_comparable_type_id;
229 comparable_tests_test_comparable_type_id = g_type_register_static (G_TYPE_OBJECT, "ComparableTestsTestComparable", &g_define_type_info, 0);
230 g_type_add_interface_static (comparable_tests_test_comparable_type_id, GEE_TYPE_COMPARABLE, &gee_comparable_info);
231 g_once_init_leave (&comparable_tests_test_comparable_type_id__volatile, comparable_tests_test_comparable_type_id);
232 }
233 return comparable_tests_test_comparable_type_id__volatile;
234 }
235
236
comparable_tests_class_init(ComparableTestsClass * klass)237 static void comparable_tests_class_init (ComparableTestsClass * klass) {
238 comparable_tests_parent_class = g_type_class_peek_parent (klass);
239 }
240
241
comparable_tests_instance_init(ComparableTests * self)242 static void comparable_tests_instance_init (ComparableTests * self) {
243 }
244
245
comparable_tests_get_type(void)246 GType comparable_tests_get_type (void) {
247 static volatile gsize comparable_tests_type_id__volatile = 0;
248 if (g_once_init_enter (&comparable_tests_type_id__volatile)) {
249 static const GTypeInfo g_define_type_info = { sizeof (ComparableTestsClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) comparable_tests_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (ComparableTests), 0, (GInstanceInitFunc) comparable_tests_instance_init, NULL };
250 GType comparable_tests_type_id;
251 comparable_tests_type_id = g_type_register_static (GEE_TYPE_TEST_CASE, "ComparableTests", &g_define_type_info, 0);
252 g_once_init_leave (&comparable_tests_type_id__volatile, comparable_tests_type_id);
253 }
254 return comparable_tests_type_id__volatile;
255 }
256
257
258
259