1 /* testpriorityqueue.c generated by valac 0.18.0, the Vala compiler
2 * generated from testpriorityqueue.vala, do not modify */
4 /* testpriorityqueue.vala
6 * Copyright (C) 2009 Didier Villevalois
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 * Didier 'Ptitjes Villevalois <ptitjes@free.fr>
27 #include <glib-object.h>
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))
40 typedef struct _GeeTestCase GeeTestCase;
41 typedef struct _GeeTestCaseClass GeeTestCaseClass;
42 typedef struct _GeeTestCasePrivate GeeTestCasePrivate;
44 #define TYPE_COLLECTION_TESTS (collection_tests_get_type ())
45 #define COLLECTION_TESTS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_COLLECTION_TESTS, CollectionTests))
46 #define COLLECTION_TESTS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_COLLECTION_TESTS, CollectionTestsClass))
47 #define IS_COLLECTION_TESTS(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_COLLECTION_TESTS))
48 #define IS_COLLECTION_TESTS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_COLLECTION_TESTS))
49 #define COLLECTION_TESTS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_COLLECTION_TESTS, CollectionTestsClass))
51 typedef struct _CollectionTests CollectionTests;
52 typedef struct _CollectionTestsClass CollectionTestsClass;
53 typedef struct _CollectionTestsPrivate CollectionTestsPrivate;
55 #define TYPE_QUEUE_TESTS (queue_tests_get_type ())
56 #define QUEUE_TESTS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_QUEUE_TESTS, QueueTests))
57 #define QUEUE_TESTS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_QUEUE_TESTS, QueueTestsClass))
58 #define IS_QUEUE_TESTS(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_QUEUE_TESTS))
59 #define IS_QUEUE_TESTS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_QUEUE_TESTS))
60 #define QUEUE_TESTS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_QUEUE_TESTS, QueueTestsClass))
62 typedef struct _QueueTests QueueTests;
63 typedef struct _QueueTestsClass QueueTestsClass;
64 typedef struct _QueueTestsPrivate QueueTestsPrivate;
66 #define TYPE_PRIORITY_QUEUE_TESTS (priority_queue_tests_get_type ())
67 #define PRIORITY_QUEUE_TESTS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_PRIORITY_QUEUE_TESTS, PriorityQueueTests))
68 #define PRIORITY_QUEUE_TESTS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_PRIORITY_QUEUE_TESTS, PriorityQueueTestsClass))
69 #define IS_PRIORITY_QUEUE_TESTS(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_PRIORITY_QUEUE_TESTS))
70 #define IS_PRIORITY_QUEUE_TESTS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_PRIORITY_QUEUE_TESTS))
71 #define PRIORITY_QUEUE_TESTS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_PRIORITY_QUEUE_TESTS, PriorityQueueTestsClass))
73 typedef struct _PriorityQueueTests PriorityQueueTests;
74 typedef struct _PriorityQueueTestsClass PriorityQueueTestsClass;
75 typedef struct _PriorityQueueTestsPrivate PriorityQueueTestsPrivate;
76 #define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
77 #define _g_free0(var) (var = (g_free (var), NULL))
78 #define _vala_assert(expr, msg) if G_LIKELY (expr) ; else g_assertion_message_expr (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, msg);
81 GObject parent_instance;
82 GeeTestCasePrivate * priv;
85 struct _GeeTestCaseClass {
86 GObjectClass parent_class;
87 void (*set_up) (GeeTestCase* self);
88 void (*tear_down) (GeeTestCase* self);
91 struct _CollectionTests {
92 GeeTestCase parent_instance;
93 CollectionTestsPrivate * priv;
94 GeeCollection* test_collection;
97 struct _CollectionTestsClass {
98 GeeTestCaseClass parent_class;
102 CollectionTests parent_instance;
103 QueueTestsPrivate * priv;
106 struct _QueueTestsClass {
107 CollectionTestsClass parent_class;
110 struct _PriorityQueueTests {
111 QueueTests parent_instance;
112 PriorityQueueTestsPrivate * priv;
115 struct _PriorityQueueTestsClass {
116 QueueTestsClass parent_class;
119 typedef void (*GeeTestCaseTestMethod) (void* user_data);
121 static gpointer priority_queue_tests_parent_class = NULL;
123 GType gee_test_case_get_type (void) G_GNUC_CONST;
124 GType collection_tests_get_type (void) G_GNUC_CONST;
125 GType queue_tests_get_type (void) G_GNUC_CONST;
126 GType priority_queue_tests_get_type (void) G_GNUC_CONST;
128 PRIORITY_QUEUE_TESTS_DUMMY_PROPERTY
130 PriorityQueueTests* priority_queue_tests_new (void);
131 PriorityQueueTests* priority_queue_tests_construct (GType object_type);
132 QueueTests* queue_tests_construct (GType object_type, const gchar* name);
133 void gee_test_case_add_test (GeeTestCase* self, const gchar* name, GeeTestCaseTestMethod test, void* test_target, GDestroyNotify test_target_destroy_notify);
134 static void priority_queue_tests_test_poll_gives_minimum (PriorityQueueTests* self);
135 static void _priority_queue_tests_test_poll_gives_minimum_gee_test_case_test_method (gpointer self);
136 static void priority_queue_tests_real_set_up (GeeTestCase* base);
137 static void priority_queue_tests_real_tear_down (GeeTestCase* base);
140 static void _priority_queue_tests_test_poll_gives_minimum_gee_test_case_test_method (gpointer self) {
141 priority_queue_tests_test_poll_gives_minimum (self);
145 PriorityQueueTests* priority_queue_tests_construct (GType object_type) {
146 PriorityQueueTests * self = NULL;
147 self = (PriorityQueueTests*) queue_tests_construct (object_type, "PriorityQueue");
148 gee_test_case_add_test ((GeeTestCase*) self, "[PriorityQueue] poll gives minimum", _priority_queue_tests_test_poll_gives_minimum_gee_test_case_test_method, g_object_ref (self), g_object_unref);
153 PriorityQueueTests* priority_queue_tests_new (void) {
154 return priority_queue_tests_construct (TYPE_PRIORITY_QUEUE_TESTS);
158 static void priority_queue_tests_real_set_up (GeeTestCase* base) {
159 PriorityQueueTests * self;
160 GeePriorityQueue* _tmp0_;
161 self = (PriorityQueueTests*) base;
162 _tmp0_ = gee_priority_queue_new (G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, g_free, NULL, NULL, NULL);
163 _g_object_unref0 (((CollectionTests*) self)->test_collection);
164 ((CollectionTests*) self)->test_collection = (GeeCollection*) _tmp0_;
168 static void priority_queue_tests_real_tear_down (GeeTestCase* base) {
169 PriorityQueueTests * self;
170 self = (PriorityQueueTests*) base;
171 _g_object_unref0 (((CollectionTests*) self)->test_collection);
172 ((CollectionTests*) self)->test_collection = NULL;
176 static gpointer _g_object_ref0 (gpointer self) {
177 return self ? g_object_ref (self) : NULL;
181 static void priority_queue_tests_test_poll_gives_minimum (PriorityQueueTests* self) {
182 GeeCollection* _tmp0_;
184 GeeQueue* test_queue;
185 gboolean _tmp2_ = FALSE;
186 gboolean _tmp3_ = FALSE;
187 gpointer _tmp4_ = NULL;
189 gboolean _tmp6_ = FALSE;
190 gpointer _tmp7_ = NULL;
192 gpointer _tmp9_ = NULL;
194 gboolean _tmp11_ = FALSE;
195 gboolean _tmp12_ = FALSE;
196 gboolean _tmp13_ = FALSE;
197 gboolean _tmp14_ = FALSE;
198 gboolean _tmp15_ = FALSE;
199 gboolean _tmp16_ = FALSE;
200 gboolean _tmp17_ = FALSE;
201 gboolean _tmp18_ = FALSE;
202 gboolean _tmp19_ = FALSE;
203 gboolean _tmp20_ = FALSE;
204 gboolean _tmp21_ = FALSE;
205 gboolean _tmp22_ = FALSE;
206 gpointer _tmp23_ = NULL;
208 gpointer _tmp25_ = NULL;
210 gpointer _tmp27_ = NULL;
212 gpointer _tmp29_ = NULL;
214 gpointer _tmp31_ = NULL;
216 gpointer _tmp33_ = NULL;
218 gpointer _tmp35_ = NULL;
220 gpointer _tmp37_ = NULL;
222 gpointer _tmp39_ = NULL;
224 gpointer _tmp41_ = NULL;
226 gpointer _tmp43_ = NULL;
228 gpointer _tmp45_ = NULL;
230 gpointer _tmp47_ = NULL;
232 gpointer _tmp49_ = NULL;
234 gpointer _tmp51_ = NULL;
236 gpointer _tmp53_ = NULL;
238 gpointer _tmp55_ = NULL;
240 gpointer _tmp57_ = NULL;
242 gpointer _tmp59_ = NULL;
244 gpointer _tmp61_ = NULL;
246 gpointer _tmp63_ = NULL;
248 gpointer _tmp65_ = NULL;
250 gpointer _tmp67_ = NULL;
252 gpointer _tmp69_ = NULL;
254 gboolean _tmp71_ = FALSE;
255 gboolean _tmp72_ = FALSE;
256 gpointer _tmp73_ = NULL;
258 gpointer _tmp75_ = NULL;
260 gpointer _tmp77_ = NULL;
262 gpointer _tmp79_ = NULL;
264 g_return_if_fail (self != NULL);
265 _tmp0_ = ((CollectionTests*) self)->test_collection;
266 _tmp1_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_TYPE (_tmp0_, GEE_TYPE_QUEUE) ? ((GeeQueue*) _tmp0_) : NULL);
268 _vala_assert (test_queue != NULL, "test_queue != null");
269 _tmp2_ = gee_queue_offer (test_queue, "one");
270 _vala_assert (_tmp2_, "test_queue.offer (\"one\")");
271 _tmp3_ = gee_queue_offer (test_queue, "two");
272 _vala_assert (_tmp3_, "test_queue.offer (\"two\")");
273 _tmp4_ = gee_queue_peek (test_queue);
274 _tmp5_ = (gchar*) _tmp4_;
275 _vala_assert (g_strcmp0 (_tmp5_, "one") == 0, "test_queue.peek () == \"one\"");
277 _tmp6_ = gee_collection_remove ((GeeCollection*) test_queue, "two");
278 _vala_assert (_tmp6_, "test_queue.remove (\"two\")");
279 _tmp7_ = gee_queue_peek (test_queue);
280 _tmp8_ = (gchar*) _tmp7_;
281 _vala_assert (g_strcmp0 (_tmp8_, "one") == 0, "test_queue.peek () == \"one\"");
283 _tmp9_ = gee_queue_poll (test_queue);
284 _tmp10_ = (gchar*) _tmp9_;
285 _vala_assert (g_strcmp0 (_tmp10_, "one") == 0, "test_queue.poll () == \"one\"");
287 _tmp11_ = gee_queue_offer (test_queue, "one");
288 _vala_assert (_tmp11_, "test_queue.offer (\"one\")");
289 _tmp12_ = gee_queue_offer (test_queue, "two");
290 _vala_assert (_tmp12_, "test_queue.offer (\"two\")");
291 _tmp13_ = gee_queue_offer (test_queue, "three");
292 _vala_assert (_tmp13_, "test_queue.offer (\"three\")");
293 _tmp14_ = gee_queue_offer (test_queue, "four");
294 _vala_assert (_tmp14_, "test_queue.offer (\"four\")");
295 _tmp15_ = gee_queue_offer (test_queue, "five");
296 _vala_assert (_tmp15_, "test_queue.offer (\"five\")");
297 _tmp16_ = gee_queue_offer (test_queue, "six");
298 _vala_assert (_tmp16_, "test_queue.offer (\"six\")");
299 _tmp17_ = gee_queue_offer (test_queue, "seven");
300 _vala_assert (_tmp17_, "test_queue.offer (\"seven\")");
301 _tmp18_ = gee_queue_offer (test_queue, "eight");
302 _vala_assert (_tmp18_, "test_queue.offer (\"eight\")");
303 _tmp19_ = gee_queue_offer (test_queue, "nine");
304 _vala_assert (_tmp19_, "test_queue.offer (\"nine\")");
305 _tmp20_ = gee_queue_offer (test_queue, "ten");
306 _vala_assert (_tmp20_, "test_queue.offer (\"ten\")");
307 _tmp21_ = gee_queue_offer (test_queue, "eleven");
308 _vala_assert (_tmp21_, "test_queue.offer (\"eleven\")");
309 _tmp22_ = gee_queue_offer (test_queue, "twelve");
310 _vala_assert (_tmp22_, "test_queue.offer (\"twelve\")");
311 _tmp23_ = gee_queue_peek (test_queue);
312 _tmp24_ = (gchar*) _tmp23_;
313 _vala_assert (g_strcmp0 (_tmp24_, "eight") == 0, "test_queue.peek () == \"eight\"");
315 _tmp25_ = gee_queue_poll (test_queue);
316 _tmp26_ = (gchar*) _tmp25_;
317 _vala_assert (g_strcmp0 (_tmp26_, "eight") == 0, "test_queue.poll () == \"eight\"");
319 _tmp27_ = gee_queue_peek (test_queue);
320 _tmp28_ = (gchar*) _tmp27_;
321 _vala_assert (g_strcmp0 (_tmp28_, "eleven") == 0, "test_queue.peek () == \"eleven\"");
323 _tmp29_ = gee_queue_poll (test_queue);
324 _tmp30_ = (gchar*) _tmp29_;
325 _vala_assert (g_strcmp0 (_tmp30_, "eleven") == 0, "test_queue.poll () == \"eleven\"");
327 _tmp31_ = gee_queue_peek (test_queue);
328 _tmp32_ = (gchar*) _tmp31_;
329 _vala_assert (g_strcmp0 (_tmp32_, "five") == 0, "test_queue.peek () == \"five\"");
331 _tmp33_ = gee_queue_poll (test_queue);
332 _tmp34_ = (gchar*) _tmp33_;
333 _vala_assert (g_strcmp0 (_tmp34_, "five") == 0, "test_queue.poll () == \"five\"");
335 _tmp35_ = gee_queue_peek (test_queue);
336 _tmp36_ = (gchar*) _tmp35_;
337 _vala_assert (g_strcmp0 (_tmp36_, "four") == 0, "test_queue.peek () == \"four\"");
339 _tmp37_ = gee_queue_poll (test_queue);
340 _tmp38_ = (gchar*) _tmp37_;
341 _vala_assert (g_strcmp0 (_tmp38_, "four") == 0, "test_queue.poll () == \"four\"");
343 _tmp39_ = gee_queue_peek (test_queue);
344 _tmp40_ = (gchar*) _tmp39_;
345 _vala_assert (g_strcmp0 (_tmp40_, "nine") == 0, "test_queue.peek () == \"nine\"");
347 _tmp41_ = gee_queue_poll (test_queue);
348 _tmp42_ = (gchar*) _tmp41_;
349 _vala_assert (g_strcmp0 (_tmp42_, "nine") == 0, "test_queue.poll () == \"nine\"");
351 _tmp43_ = gee_queue_peek (test_queue);
352 _tmp44_ = (gchar*) _tmp43_;
353 _vala_assert (g_strcmp0 (_tmp44_, "one") == 0, "test_queue.peek () == \"one\"");
355 _tmp45_ = gee_queue_poll (test_queue);
356 _tmp46_ = (gchar*) _tmp45_;
357 _vala_assert (g_strcmp0 (_tmp46_, "one") == 0, "test_queue.poll () == \"one\"");
359 _tmp47_ = gee_queue_peek (test_queue);
360 _tmp48_ = (gchar*) _tmp47_;
361 _vala_assert (g_strcmp0 (_tmp48_, "seven") == 0, "test_queue.peek () == \"seven\"");
363 _tmp49_ = gee_queue_poll (test_queue);
364 _tmp50_ = (gchar*) _tmp49_;
365 _vala_assert (g_strcmp0 (_tmp50_, "seven") == 0, "test_queue.poll () == \"seven\"");
367 _tmp51_ = gee_queue_peek (test_queue);
368 _tmp52_ = (gchar*) _tmp51_;
369 _vala_assert (g_strcmp0 (_tmp52_, "six") == 0, "test_queue.peek () == \"six\"");
371 _tmp53_ = gee_queue_poll (test_queue);
372 _tmp54_ = (gchar*) _tmp53_;
373 _vala_assert (g_strcmp0 (_tmp54_, "six") == 0, "test_queue.poll () == \"six\"");
375 _tmp55_ = gee_queue_peek (test_queue);
376 _tmp56_ = (gchar*) _tmp55_;
377 _vala_assert (g_strcmp0 (_tmp56_, "ten") == 0, "test_queue.peek () == \"ten\"");
379 _tmp57_ = gee_queue_poll (test_queue);
380 _tmp58_ = (gchar*) _tmp57_;
381 _vala_assert (g_strcmp0 (_tmp58_, "ten") == 0, "test_queue.poll () == \"ten\"");
383 _tmp59_ = gee_queue_peek (test_queue);
384 _tmp60_ = (gchar*) _tmp59_;
385 _vala_assert (g_strcmp0 (_tmp60_, "three") == 0, "test_queue.peek () == \"three\"");
387 _tmp61_ = gee_queue_poll (test_queue);
388 _tmp62_ = (gchar*) _tmp61_;
389 _vala_assert (g_strcmp0 (_tmp62_, "three") == 0, "test_queue.poll () == \"three\"");
391 _tmp63_ = gee_queue_peek (test_queue);
392 _tmp64_ = (gchar*) _tmp63_;
393 _vala_assert (g_strcmp0 (_tmp64_, "twelve") == 0, "test_queue.peek () == \"twelve\"");
395 _tmp65_ = gee_queue_poll (test_queue);
396 _tmp66_ = (gchar*) _tmp65_;
397 _vala_assert (g_strcmp0 (_tmp66_, "twelve") == 0, "test_queue.poll () == \"twelve\"");
399 _tmp67_ = gee_queue_peek (test_queue);
400 _tmp68_ = (gchar*) _tmp67_;
401 _vala_assert (g_strcmp0 (_tmp68_, "two") == 0, "test_queue.peek () == \"two\"");
403 _tmp69_ = gee_queue_poll (test_queue);
404 _tmp70_ = (gchar*) _tmp69_;
405 _vala_assert (g_strcmp0 (_tmp70_, "two") == 0, "test_queue.poll () == \"two\"");
407 _tmp71_ = gee_queue_offer (test_queue, "2");
408 _vala_assert (_tmp71_, "test_queue.offer (\"2\")");
409 _tmp72_ = gee_queue_offer (test_queue, "1");
410 _vala_assert (_tmp72_, "test_queue.offer (\"1\")");
411 _tmp73_ = gee_queue_peek (test_queue);
412 _tmp74_ = (gchar*) _tmp73_;
413 _vala_assert (g_strcmp0 (_tmp74_, "1") == 0, "test_queue.peek () == \"1\"");
415 _tmp75_ = gee_queue_poll (test_queue);
416 _tmp76_ = (gchar*) _tmp75_;
417 _vala_assert (g_strcmp0 (_tmp76_, "1") == 0, "test_queue.poll () == \"1\"");
419 _tmp77_ = gee_queue_peek (test_queue);
420 _tmp78_ = (gchar*) _tmp77_;
421 _vala_assert (g_strcmp0 (_tmp78_, "2") == 0, "test_queue.peek () == \"2\"");
423 _tmp79_ = gee_queue_poll (test_queue);
424 _tmp80_ = (gchar*) _tmp79_;
425 _vala_assert (g_strcmp0 (_tmp80_, "2") == 0, "test_queue.poll () == \"2\"");
427 _g_object_unref0 (test_queue);
431 static void priority_queue_tests_class_init (PriorityQueueTestsClass * klass) {
432 priority_queue_tests_parent_class = g_type_class_peek_parent (klass);
433 GEE_TEST_CASE_CLASS (klass)->set_up = priority_queue_tests_real_set_up;
434 GEE_TEST_CASE_CLASS (klass)->tear_down = priority_queue_tests_real_tear_down;
438 static void priority_queue_tests_instance_init (PriorityQueueTests * self) {
442 GType priority_queue_tests_get_type (void) {
443 static volatile gsize priority_queue_tests_type_id__volatile = 0;
444 if (g_once_init_enter (&priority_queue_tests_type_id__volatile)) {
445 static const GTypeInfo g_define_type_info = { sizeof (PriorityQueueTestsClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) priority_queue_tests_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (PriorityQueueTests), 0, (GInstanceInitFunc) priority_queue_tests_instance_init, NULL };
446 GType priority_queue_tests_type_id;
447 priority_queue_tests_type_id = g_type_register_static (TYPE_QUEUE_TESTS, "PriorityQueueTests", &g_define_type_info, 0);
448 g_once_init_leave (&priority_queue_tests_type_id__volatile, priority_queue_tests_type_id);
450 return priority_queue_tests_type_id__volatile;