1 /* testlinkedlist.c generated by valac 0.18.0, the Vala compiler
2 * generated from testlinkedlist.vala, do not modify */
6 * Copyright (C) 2008 Jürg Billeter
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.
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.
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
23 * Jürg Billeter <j@bitron.ch>
24 * Mark Lee <marklee@src.gnome.org> (port to LinkedList)
25 * Julien Peeters <contact@julienpeeters.fr>
29 #include <glib-object.h>
35 #define GEE_TYPE_TEST_CASE (gee_test_case_get_type ())
36 #define GEE_TEST_CASE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GEE_TYPE_TEST_CASE, GeeTestCase))
37 #define GEE_TEST_CASE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GEE_TYPE_TEST_CASE, GeeTestCaseClass))
38 #define GEE_IS_TEST_CASE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GEE_TYPE_TEST_CASE))
39 #define GEE_IS_TEST_CASE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GEE_TYPE_TEST_CASE))
40 #define GEE_TEST_CASE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GEE_TYPE_TEST_CASE, GeeTestCaseClass))
42 typedef struct _GeeTestCase GeeTestCase;
43 typedef struct _GeeTestCaseClass GeeTestCaseClass;
44 typedef struct _GeeTestCasePrivate GeeTestCasePrivate;
46 #define TYPE_COLLECTION_TESTS (collection_tests_get_type ())
47 #define COLLECTION_TESTS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_COLLECTION_TESTS, CollectionTests))
48 #define COLLECTION_TESTS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_COLLECTION_TESTS, CollectionTestsClass))
49 #define IS_COLLECTION_TESTS(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_COLLECTION_TESTS))
50 #define IS_COLLECTION_TESTS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_COLLECTION_TESTS))
51 #define COLLECTION_TESTS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_COLLECTION_TESTS, CollectionTestsClass))
53 typedef struct _CollectionTests CollectionTests;
54 typedef struct _CollectionTestsClass CollectionTestsClass;
55 typedef struct _CollectionTestsPrivate CollectionTestsPrivate;
57 #define TYPE_LIST_TESTS (list_tests_get_type ())
58 #define LIST_TESTS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_LIST_TESTS, ListTests))
59 #define LIST_TESTS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_LIST_TESTS, ListTestsClass))
60 #define IS_LIST_TESTS(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_LIST_TESTS))
61 #define IS_LIST_TESTS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_LIST_TESTS))
62 #define LIST_TESTS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_LIST_TESTS, ListTestsClass))
64 typedef struct _ListTests ListTests;
65 typedef struct _ListTestsClass ListTestsClass;
66 typedef struct _ListTestsPrivate ListTestsPrivate;
68 #define TYPE_BIDIR_LIST_TESTS (bidir_list_tests_get_type ())
69 #define BIDIR_LIST_TESTS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_BIDIR_LIST_TESTS, BidirListTests))
70 #define BIDIR_LIST_TESTS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_BIDIR_LIST_TESTS, BidirListTestsClass))
71 #define IS_BIDIR_LIST_TESTS(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_BIDIR_LIST_TESTS))
72 #define IS_BIDIR_LIST_TESTS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_BIDIR_LIST_TESTS))
73 #define BIDIR_LIST_TESTS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_BIDIR_LIST_TESTS, BidirListTestsClass))
75 typedef struct _BidirListTests BidirListTests;
76 typedef struct _BidirListTestsClass BidirListTestsClass;
77 typedef struct _BidirListTestsPrivate BidirListTestsPrivate;
79 #define TYPE_LINKED_LIST_TESTS (linked_list_tests_get_type ())
80 #define LINKED_LIST_TESTS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_LINKED_LIST_TESTS, LinkedListTests))
81 #define LINKED_LIST_TESTS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_LINKED_LIST_TESTS, LinkedListTestsClass))
82 #define IS_LINKED_LIST_TESTS(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_LINKED_LIST_TESTS))
83 #define IS_LINKED_LIST_TESTS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_LINKED_LIST_TESTS))
84 #define LINKED_LIST_TESTS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_LINKED_LIST_TESTS, LinkedListTestsClass))
86 typedef struct _LinkedListTests LinkedListTests;
87 typedef struct _LinkedListTestsClass LinkedListTestsClass;
88 typedef struct _LinkedListTestsPrivate LinkedListTestsPrivate;
89 #define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
90 #define _g_free0(var) (var = (g_free (var), NULL))
91 #define _vala_assert(expr, msg) if G_LIKELY (expr) ; else g_assertion_message_expr (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, msg);
94 GObject parent_instance;
95 GeeTestCasePrivate * priv;
98 struct _GeeTestCaseClass {
99 GObjectClass parent_class;
100 void (*set_up) (GeeTestCase* self);
101 void (*tear_down) (GeeTestCase* self);
104 struct _CollectionTests {
105 GeeTestCase parent_instance;
106 CollectionTestsPrivate * priv;
107 GeeCollection* test_collection;
110 struct _CollectionTestsClass {
111 GeeTestCaseClass parent_class;
115 CollectionTests parent_instance;
116 ListTestsPrivate * priv;
119 struct _ListTestsClass {
120 CollectionTestsClass parent_class;
121 void (*test_duplicates_are_retained) (ListTests* self);
124 struct _BidirListTests {
125 ListTests parent_instance;
126 BidirListTestsPrivate * priv;
129 struct _BidirListTestsClass {
130 ListTestsClass parent_class;
133 struct _LinkedListTests {
134 BidirListTests parent_instance;
135 LinkedListTestsPrivate * priv;
138 struct _LinkedListTestsClass {
139 BidirListTestsClass parent_class;
142 typedef void (*GeeTestCaseTestMethod) (void* user_data);
144 static gpointer linked_list_tests_parent_class = NULL;
146 GType gee_test_case_get_type (void) G_GNUC_CONST;
147 GType collection_tests_get_type (void) G_GNUC_CONST;
148 GType list_tests_get_type (void) G_GNUC_CONST;
149 GType bidir_list_tests_get_type (void) G_GNUC_CONST;
150 GType linked_list_tests_get_type (void) G_GNUC_CONST;
152 LINKED_LIST_TESTS_DUMMY_PROPERTY
154 LinkedListTests* linked_list_tests_new (void);
155 LinkedListTests* linked_list_tests_construct (GType object_type);
156 BidirListTests* bidir_list_tests_construct (GType object_type, const gchar* name);
157 void gee_test_case_add_test (GeeTestCase* self, const gchar* name, GeeTestCaseTestMethod test, void* test_target, GDestroyNotify test_target_destroy_notify);
158 static void linked_list_tests_test_sort (LinkedListTests* self);
159 static void _linked_list_tests_test_sort_gee_test_case_test_method (gpointer self);
160 static void linked_list_tests_real_set_up (GeeTestCase* base);
161 static void linked_list_tests_real_tear_down (GeeTestCase* base);
164 static void _linked_list_tests_test_sort_gee_test_case_test_method (gpointer self) {
165 linked_list_tests_test_sort (self);
169 LinkedListTests* linked_list_tests_construct (GType object_type) {
170 LinkedListTests * self = NULL;
171 self = (LinkedListTests*) bidir_list_tests_construct (object_type, "LinkedList");
172 gee_test_case_add_test ((GeeTestCase*) self, "[LinkedList] sort", _linked_list_tests_test_sort_gee_test_case_test_method, g_object_ref (self), g_object_unref);
177 LinkedListTests* linked_list_tests_new (void) {
178 return linked_list_tests_construct (TYPE_LINKED_LIST_TESTS);
182 static void linked_list_tests_real_set_up (GeeTestCase* base) {
183 LinkedListTests * self;
184 GeeLinkedList* _tmp0_;
185 self = (LinkedListTests*) base;
186 _tmp0_ = gee_linked_list_new (G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, g_free, NULL, NULL, NULL);
187 _g_object_unref0 (((CollectionTests*) self)->test_collection);
188 ((CollectionTests*) self)->test_collection = (GeeCollection*) _tmp0_;
192 static void linked_list_tests_real_tear_down (GeeTestCase* base) {
193 LinkedListTests * self;
194 self = (LinkedListTests*) base;
195 _g_object_unref0 (((CollectionTests*) self)->test_collection);
196 ((CollectionTests*) self)->test_collection = NULL;
200 static gpointer _g_object_ref0 (gpointer self) {
201 return self ? g_object_ref (self) : NULL;
205 static void linked_list_tests_test_sort (LinkedListTests* self) {
206 GeeCollection* _tmp0_;
207 GeeLinkedList* _tmp1_;
208 GeeLinkedList* test_list;
209 gpointer _tmp2_ = NULL;
211 gpointer _tmp4_ = NULL;
213 gpointer _tmp6_ = NULL;
215 gpointer _tmp8_ = NULL;
217 gpointer _tmp10_ = NULL;
219 gpointer _tmp12_ = NULL;
221 gpointer _tmp14_ = NULL;
223 gpointer _tmp16_ = NULL;
225 gpointer _tmp18_ = NULL;
227 gpointer _tmp20_ = NULL;
229 gpointer _tmp22_ = NULL;
231 gpointer _tmp24_ = NULL;
233 g_return_if_fail (self != NULL);
234 _tmp0_ = ((CollectionTests*) self)->test_collection;
235 _tmp1_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_TYPE (_tmp0_, GEE_TYPE_LINKED_LIST) ? ((GeeLinkedList*) _tmp0_) : NULL);
237 _vala_assert (test_list != NULL, "test_list != null");
238 gee_abstract_collection_add ((GeeAbstractCollection*) test_list, "one");
239 gee_abstract_collection_add ((GeeAbstractCollection*) test_list, "two");
240 gee_abstract_collection_add ((GeeAbstractCollection*) test_list, "three");
241 gee_abstract_collection_add ((GeeAbstractCollection*) test_list, "four");
242 gee_abstract_collection_add ((GeeAbstractCollection*) test_list, "five");
243 gee_abstract_collection_add ((GeeAbstractCollection*) test_list, "six");
244 gee_abstract_collection_add ((GeeAbstractCollection*) test_list, "seven");
245 gee_abstract_collection_add ((GeeAbstractCollection*) test_list, "eight");
246 gee_abstract_collection_add ((GeeAbstractCollection*) test_list, "nine");
247 gee_abstract_collection_add ((GeeAbstractCollection*) test_list, "ten");
248 gee_abstract_collection_add ((GeeAbstractCollection*) test_list, "eleven");
249 gee_abstract_collection_add ((GeeAbstractCollection*) test_list, "twelve");
250 gee_list_sort ((GeeList*) test_list, NULL, NULL, NULL);
251 _tmp2_ = gee_abstract_list_get ((GeeAbstractList*) test_list, 0);
252 _tmp3_ = (gchar*) _tmp2_;
253 _vala_assert (g_strcmp0 (_tmp3_, "eight") == 0, "test_list.get (0) == \"eight\"");
255 _tmp4_ = gee_abstract_list_get ((GeeAbstractList*) test_list, 1);
256 _tmp5_ = (gchar*) _tmp4_;
257 _vala_assert (g_strcmp0 (_tmp5_, "eleven") == 0, "test_list.get (1) == \"eleven\"");
259 _tmp6_ = gee_abstract_list_get ((GeeAbstractList*) test_list, 2);
260 _tmp7_ = (gchar*) _tmp6_;
261 _vala_assert (g_strcmp0 (_tmp7_, "five") == 0, "test_list.get (2) == \"five\"");
263 _tmp8_ = gee_abstract_list_get ((GeeAbstractList*) test_list, 3);
264 _tmp9_ = (gchar*) _tmp8_;
265 _vala_assert (g_strcmp0 (_tmp9_, "four") == 0, "test_list.get (3) == \"four\"");
267 _tmp10_ = gee_abstract_list_get ((GeeAbstractList*) test_list, 4);
268 _tmp11_ = (gchar*) _tmp10_;
269 _vala_assert (g_strcmp0 (_tmp11_, "nine") == 0, "test_list.get (4) == \"nine\"");
271 _tmp12_ = gee_abstract_list_get ((GeeAbstractList*) test_list, 5);
272 _tmp13_ = (gchar*) _tmp12_;
273 _vala_assert (g_strcmp0 (_tmp13_, "one") == 0, "test_list.get (5) == \"one\"");
275 _tmp14_ = gee_abstract_list_get ((GeeAbstractList*) test_list, 6);
276 _tmp15_ = (gchar*) _tmp14_;
277 _vala_assert (g_strcmp0 (_tmp15_, "seven") == 0, "test_list.get (6) == \"seven\"");
279 _tmp16_ = gee_abstract_list_get ((GeeAbstractList*) test_list, 7);
280 _tmp17_ = (gchar*) _tmp16_;
281 _vala_assert (g_strcmp0 (_tmp17_, "six") == 0, "test_list.get (7) == \"six\"");
283 _tmp18_ = gee_abstract_list_get ((GeeAbstractList*) test_list, 8);
284 _tmp19_ = (gchar*) _tmp18_;
285 _vala_assert (g_strcmp0 (_tmp19_, "ten") == 0, "test_list.get (8) == \"ten\"");
287 _tmp20_ = gee_abstract_list_get ((GeeAbstractList*) test_list, 9);
288 _tmp21_ = (gchar*) _tmp20_;
289 _vala_assert (g_strcmp0 (_tmp21_, "three") == 0, "test_list.get (9) == \"three\"");
291 _tmp22_ = gee_abstract_list_get ((GeeAbstractList*) test_list, 10);
292 _tmp23_ = (gchar*) _tmp22_;
293 _vala_assert (g_strcmp0 (_tmp23_, "twelve") == 0, "test_list.get (10) == \"twelve\"");
295 _tmp24_ = gee_abstract_list_get ((GeeAbstractList*) test_list, 11);
296 _tmp25_ = (gchar*) _tmp24_;
297 _vala_assert (g_strcmp0 (_tmp25_, "two") == 0, "test_list.get (11) == \"two\"");
299 _g_object_unref0 (test_list);
303 static void linked_list_tests_class_init (LinkedListTestsClass * klass) {
304 linked_list_tests_parent_class = g_type_class_peek_parent (klass);
305 GEE_TEST_CASE_CLASS (klass)->set_up = linked_list_tests_real_set_up;
306 GEE_TEST_CASE_CLASS (klass)->tear_down = linked_list_tests_real_tear_down;
310 static void linked_list_tests_instance_init (LinkedListTests * self) {
314 GType linked_list_tests_get_type (void) {
315 static volatile gsize linked_list_tests_type_id__volatile = 0;
316 if (g_once_init_enter (&linked_list_tests_type_id__volatile)) {
317 static const GTypeInfo g_define_type_info = { sizeof (LinkedListTestsClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) linked_list_tests_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (LinkedListTests), 0, (GInstanceInitFunc) linked_list_tests_instance_init, NULL };
318 GType linked_list_tests_type_id;
319 linked_list_tests_type_id = g_type_register_static (TYPE_BIDIR_LIST_TESTS, "LinkedListTests", &g_define_type_info, 0);
320 g_once_init_leave (&linked_list_tests_type_id__volatile, linked_list_tests_type_id);
322 return linked_list_tests_type_id__volatile;