1 /* testreadonlycollection.c generated by valac 0.19.0.4-d6d4, the Vala compiler
2 * generated from testreadonlycollection.vala, do not modify */
3
4 /* testreadonlycollection.vala
5 *
6 * Copyright (C) 2008 Jürg Billeter
7 * Copyright (C) 2009 Didier Villevalois
8 *
9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public
11 * License as published by the Free Software Foundation; either
12 * version 2.1 of the License, or (at your option) any later version.
13
14 * This library is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Lesser General Public License for more details.
18
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with this library; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
22 *
23 * Author:
24 * Tomaž Vajngerl <quikee@gmail.com>
25 * Julien Peeters <contact@julienpeeters.fr>
26 */
27
28 #include <glib.h>
29 #include <glib-object.h>
30 #include <gee.h>
31 #include <stdlib.h>
32 #include <string.h>
33
34
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))
41
42 typedef struct _GeeTestCase GeeTestCase;
43 typedef struct _GeeTestCaseClass GeeTestCaseClass;
44 typedef struct _GeeTestCasePrivate GeeTestCasePrivate;
45
46 #define TYPE_READ_ONLY_COLLECTION_TESTS (read_only_collection_tests_get_type ())
47 #define READ_ONLY_COLLECTION_TESTS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_READ_ONLY_COLLECTION_TESTS, ReadOnlyCollectionTests))
48 #define READ_ONLY_COLLECTION_TESTS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_READ_ONLY_COLLECTION_TESTS, ReadOnlyCollectionTestsClass))
49 #define IS_READ_ONLY_COLLECTION_TESTS(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_READ_ONLY_COLLECTION_TESTS))
50 #define IS_READ_ONLY_COLLECTION_TESTS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_READ_ONLY_COLLECTION_TESTS))
51 #define READ_ONLY_COLLECTION_TESTS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_READ_ONLY_COLLECTION_TESTS, ReadOnlyCollectionTestsClass))
52
53 typedef struct _ReadOnlyCollectionTests ReadOnlyCollectionTests;
54 typedef struct _ReadOnlyCollectionTestsClass ReadOnlyCollectionTestsClass;
55 typedef struct _ReadOnlyCollectionTestsPrivate ReadOnlyCollectionTestsPrivate;
56 #define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
57 #define _vala_assert(expr, msg) if G_LIKELY (expr) ; else g_assertion_message_expr (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, msg);
58
59 struct _GeeTestCase {
60 GObject parent_instance;
61 GeeTestCasePrivate * priv;
62 };
63
64 struct _GeeTestCaseClass {
65 GObjectClass parent_class;
66 void (*set_up) (GeeTestCase* self);
67 void (*tear_down) (GeeTestCase* self);
68 };
69
70 struct _ReadOnlyCollectionTests {
71 GeeTestCase parent_instance;
72 ReadOnlyCollectionTestsPrivate * priv;
73 GeeCollection* test_collection;
74 GeeCollection* ro_collection;
75 };
76
77 struct _ReadOnlyCollectionTestsClass {
78 GeeTestCaseClass parent_class;
79 GeeCollection* (*get_ro_view) (ReadOnlyCollectionTests* self, GeeCollection* collection);
80 };
81
82 typedef void (*GeeTestCaseTestMethod) (void* user_data);
83
84 static gpointer read_only_collection_tests_parent_class = NULL;
85
86 GType gee_test_case_get_type (void) G_GNUC_CONST;
87 GType read_only_collection_tests_get_type (void) G_GNUC_CONST;
88 enum {
89 READ_ONLY_COLLECTION_TESTS_DUMMY_PROPERTY
90 };
91 ReadOnlyCollectionTests* read_only_collection_tests_new (void);
92 ReadOnlyCollectionTests* read_only_collection_tests_construct (GType object_type);
93 ReadOnlyCollectionTests* read_only_collection_tests_new_with_name (const gchar* name);
94 ReadOnlyCollectionTests* read_only_collection_tests_construct_with_name (GType object_type, const gchar* name);
95 GeeTestCase* gee_test_case_construct (GType object_type, const gchar* name);
96 void gee_test_case_add_test (GeeTestCase* self, const gchar* name, GeeTestCaseTestMethod test, void* test_target);
97 void read_only_collection_tests_test_unique_read_only_view_instance (ReadOnlyCollectionTests* self);
98 static void _read_only_collection_tests_test_unique_read_only_view_instance_gee_test_case_test_method (gpointer self);
99 void read_only_collection_tests_test_immutable_iterator (ReadOnlyCollectionTests* self);
100 static void _read_only_collection_tests_test_immutable_iterator_gee_test_case_test_method (gpointer self);
101 void read_only_collection_tests_test_immutable (ReadOnlyCollectionTests* self);
102 static void _read_only_collection_tests_test_immutable_gee_test_case_test_method (gpointer self);
103 void read_only_collection_tests_test_accurate_view (ReadOnlyCollectionTests* self);
104 static void _read_only_collection_tests_test_accurate_view_gee_test_case_test_method (gpointer self);
105 static void read_only_collection_tests_real_set_up (GeeTestCase* base);
106 GeeCollection* read_only_collection_tests_get_ro_view (ReadOnlyCollectionTests* self, GeeCollection* collection);
107 static void read_only_collection_tests_real_tear_down (GeeTestCase* base);
108 static GeeCollection* read_only_collection_tests_real_get_ro_view (ReadOnlyCollectionTests* self, GeeCollection* collection);
109 static void read_only_collection_tests_finalize (GObject* obj);
110
111
read_only_collection_tests_construct(GType object_type)112 ReadOnlyCollectionTests* read_only_collection_tests_construct (GType object_type) {
113 ReadOnlyCollectionTests * self = NULL;
114 self = (ReadOnlyCollectionTests*) read_only_collection_tests_construct_with_name (object_type, "ReadOnlyCollection");
115 return self;
116 }
117
118
read_only_collection_tests_new(void)119 ReadOnlyCollectionTests* read_only_collection_tests_new (void) {
120 return read_only_collection_tests_construct (TYPE_READ_ONLY_COLLECTION_TESTS);
121 }
122
123
_read_only_collection_tests_test_unique_read_only_view_instance_gee_test_case_test_method(gpointer self)124 static void _read_only_collection_tests_test_unique_read_only_view_instance_gee_test_case_test_method (gpointer self) {
125 read_only_collection_tests_test_unique_read_only_view_instance (self);
126 }
127
128
_read_only_collection_tests_test_immutable_iterator_gee_test_case_test_method(gpointer self)129 static void _read_only_collection_tests_test_immutable_iterator_gee_test_case_test_method (gpointer self) {
130 read_only_collection_tests_test_immutable_iterator (self);
131 }
132
133
_read_only_collection_tests_test_immutable_gee_test_case_test_method(gpointer self)134 static void _read_only_collection_tests_test_immutable_gee_test_case_test_method (gpointer self) {
135 read_only_collection_tests_test_immutable (self);
136 }
137
138
_read_only_collection_tests_test_accurate_view_gee_test_case_test_method(gpointer self)139 static void _read_only_collection_tests_test_accurate_view_gee_test_case_test_method (gpointer self) {
140 read_only_collection_tests_test_accurate_view (self);
141 }
142
143
read_only_collection_tests_construct_with_name(GType object_type,const gchar * name)144 ReadOnlyCollectionTests* read_only_collection_tests_construct_with_name (GType object_type, const gchar* name) {
145 ReadOnlyCollectionTests * self = NULL;
146 const gchar* _tmp0_;
147 g_return_val_if_fail (name != NULL, NULL);
148 _tmp0_ = name;
149 self = (ReadOnlyCollectionTests*) gee_test_case_construct (object_type, _tmp0_);
150 gee_test_case_add_test ((GeeTestCase*) self, "[ReadOnlyCollection] unique read-only view instance", _read_only_collection_tests_test_unique_read_only_view_instance_gee_test_case_test_method, self);
151 gee_test_case_add_test ((GeeTestCase*) self, "[ReadOnlyCollection] immutable iterator", _read_only_collection_tests_test_immutable_iterator_gee_test_case_test_method, self);
152 gee_test_case_add_test ((GeeTestCase*) self, "[ReadOnlyCollection] immutable", _read_only_collection_tests_test_immutable_gee_test_case_test_method, self);
153 gee_test_case_add_test ((GeeTestCase*) self, "[ReadOnlyCollection] accurate view", _read_only_collection_tests_test_accurate_view_gee_test_case_test_method, self);
154 return self;
155 }
156
157
read_only_collection_tests_new_with_name(const gchar * name)158 ReadOnlyCollectionTests* read_only_collection_tests_new_with_name (const gchar* name) {
159 return read_only_collection_tests_construct_with_name (TYPE_READ_ONLY_COLLECTION_TESTS, name);
160 }
161
162
read_only_collection_tests_real_set_up(GeeTestCase * base)163 static void read_only_collection_tests_real_set_up (GeeTestCase* base) {
164 ReadOnlyCollectionTests * self;
165 GeeHashMultiSet* _tmp0_;
166 GeeCollection* _tmp1_;
167 GeeCollection* _tmp2_ = NULL;
168 self = (ReadOnlyCollectionTests*) base;
169 _tmp0_ = gee_hash_multi_set_new (G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, g_free, NULL, NULL);
170 _g_object_unref0 (self->test_collection);
171 self->test_collection = (GeeCollection*) _tmp0_;
172 _tmp1_ = self->test_collection;
173 _tmp2_ = read_only_collection_tests_get_ro_view (self, _tmp1_);
174 _g_object_unref0 (self->ro_collection);
175 self->ro_collection = _tmp2_;
176 }
177
178
read_only_collection_tests_real_tear_down(GeeTestCase * base)179 static void read_only_collection_tests_real_tear_down (GeeTestCase* base) {
180 ReadOnlyCollectionTests * self;
181 self = (ReadOnlyCollectionTests*) base;
182 _g_object_unref0 (self->test_collection);
183 self->test_collection = NULL;
184 _g_object_unref0 (self->ro_collection);
185 self->ro_collection = NULL;
186 }
187
188
read_only_collection_tests_real_get_ro_view(ReadOnlyCollectionTests * self,GeeCollection * collection)189 static GeeCollection* read_only_collection_tests_real_get_ro_view (ReadOnlyCollectionTests* self, GeeCollection* collection) {
190 GeeCollection* result = NULL;
191 GeeCollection* _tmp0_;
192 GeeCollection* _tmp1_;
193 GeeCollection* _tmp2_;
194 g_return_val_if_fail (collection != NULL, NULL);
195 _tmp0_ = collection;
196 _tmp1_ = gee_collection_get_read_only_view (_tmp0_);
197 _tmp2_ = _tmp1_;
198 result = _tmp2_;
199 return result;
200 }
201
202
read_only_collection_tests_get_ro_view(ReadOnlyCollectionTests * self,GeeCollection * collection)203 GeeCollection* read_only_collection_tests_get_ro_view (ReadOnlyCollectionTests* self, GeeCollection* collection) {
204 g_return_val_if_fail (self != NULL, NULL);
205 return READ_ONLY_COLLECTION_TESTS_GET_CLASS (self)->get_ro_view (self, collection);
206 }
207
208
read_only_collection_tests_test_unique_read_only_view_instance(ReadOnlyCollectionTests * self)209 void read_only_collection_tests_test_unique_read_only_view_instance (ReadOnlyCollectionTests* self) {
210 GeeCollection* _tmp0_;
211 GeeCollection* _tmp1_ = NULL;
212 GeeCollection* another_ro_collection;
213 GeeCollection* _tmp2_;
214 GeeCollection* _tmp3_;
215 GeeCollection* _tmp4_;
216 GObject* _tmp5_;
217 GeeCollection* _tmp6_;
218 gconstpointer _tmp7_ = NULL;
219 GeeCollection* _tmp8_;
220 GeeCollection* _tmp9_ = NULL;
221 GeeCollection* _tmp10_;
222 gconstpointer _tmp11_ = NULL;
223 GeeCollection* _tmp12_;
224 GeeCollection* _tmp13_;
225 GeeCollection* _tmp14_ = NULL;
226 GeeCollection* _tmp15_;
227 g_return_if_fail (self != NULL);
228 _tmp0_ = self->test_collection;
229 _tmp1_ = read_only_collection_tests_get_ro_view (self, _tmp0_);
230 another_ro_collection = _tmp1_;
231 _tmp2_ = self->ro_collection;
232 _tmp3_ = another_ro_collection;
233 _vala_assert (_tmp2_ == _tmp3_, "ro_collection == another_ro_collection");
234 _tmp4_ = self->ro_collection;
235 _tmp5_ = g_object_new (G_TYPE_OBJECT, NULL);
236 g_object_set_data_full ((GObject*) _tmp4_, "marker", _tmp5_, g_object_unref);
237 _tmp6_ = another_ro_collection;
238 _tmp7_ = g_object_get_data ((GObject*) _tmp6_, "marker");
239 _vala_assert (((GObject*) _tmp7_) != NULL, "another_ro_collection.get_data<Object> (\"marker\") != null");
240 _g_object_unref0 (another_ro_collection);
241 another_ro_collection = NULL;
242 _g_object_unref0 (self->ro_collection);
243 self->ro_collection = NULL;
244 _tmp8_ = self->test_collection;
245 _tmp9_ = read_only_collection_tests_get_ro_view (self, _tmp8_);
246 _g_object_unref0 (another_ro_collection);
247 another_ro_collection = _tmp9_;
248 _tmp10_ = another_ro_collection;
249 _tmp11_ = g_object_get_data ((GObject*) _tmp10_, "marker");
250 _vala_assert (((GObject*) _tmp11_) == NULL, "another_ro_collection.get_data<Object> (\"marker\") == null");
251 _tmp12_ = another_ro_collection;
252 _tmp13_ = another_ro_collection;
253 _tmp14_ = read_only_collection_tests_get_ro_view (self, _tmp13_);
254 _tmp15_ = _tmp14_;
255 _vala_assert (_tmp12_ == _tmp15_, "another_ro_collection == get_ro_view (another_ro_collection)");
256 _g_object_unref0 (_tmp15_);
257 _g_object_unref0 (another_ro_collection);
258 }
259
260
read_only_collection_tests_test_immutable_iterator(ReadOnlyCollectionTests * self)261 void read_only_collection_tests_test_immutable_iterator (ReadOnlyCollectionTests* self) {
262 GeeCollection* _tmp0_;
263 gboolean _tmp1_ = FALSE;
264 GeeCollection* _tmp2_;
265 gboolean _tmp3_ = FALSE;
266 GeeCollection* _tmp4_;
267 gint _tmp5_;
268 gint _tmp6_;
269 GeeCollection* _tmp7_;
270 gboolean _tmp8_ = FALSE;
271 GeeCollection* _tmp9_;
272 gboolean _tmp10_ = FALSE;
273 GeeCollection* _tmp11_;
274 GeeIterator* _tmp12_ = NULL;
275 GeeIterator* iterator;
276 gboolean one_found;
277 gboolean two_found;
278 gboolean _tmp22_;
279 gboolean _tmp23_;
280 GeeIterator* _tmp24_;
281 gboolean _tmp25_ = FALSE;
282 GeeIterator* _tmp26_;
283 gboolean _tmp27_ = FALSE;
284 GeeIterator* _tmp28_;
285 gboolean _tmp29_ = FALSE;
286 gboolean _tmp30_ = FALSE;
287 GeeCollection* _tmp32_;
288 gint _tmp33_;
289 gint _tmp34_;
290 GeeCollection* _tmp35_;
291 gboolean _tmp36_ = FALSE;
292 GeeCollection* _tmp37_;
293 gboolean _tmp38_ = FALSE;
294 g_return_if_fail (self != NULL);
295 _tmp0_ = self->test_collection;
296 _tmp1_ = gee_collection_add (_tmp0_, "one");
297 _vala_assert (_tmp1_, "test_collection.add (\"one\")");
298 _tmp2_ = self->test_collection;
299 _tmp3_ = gee_collection_add (_tmp2_, "two");
300 _vala_assert (_tmp3_, "test_collection.add (\"two\")");
301 _tmp4_ = self->ro_collection;
302 _tmp5_ = gee_collection_get_size (_tmp4_);
303 _tmp6_ = _tmp5_;
304 _vala_assert (_tmp6_ == 2, "ro_collection.size == 2");
305 _tmp7_ = self->ro_collection;
306 _tmp8_ = gee_collection_contains (_tmp7_, "one");
307 _vala_assert (_tmp8_, "ro_collection.contains (\"one\")");
308 _tmp9_ = self->ro_collection;
309 _tmp10_ = gee_collection_contains (_tmp9_, "two");
310 _vala_assert (_tmp10_, "ro_collection.contains (\"two\")");
311 _tmp11_ = self->ro_collection;
312 _tmp12_ = gee_iterable_iterator ((GeeIterable*) _tmp11_);
313 iterator = _tmp12_;
314 one_found = FALSE;
315 two_found = FALSE;
316 while (TRUE) {
317 GeeIterator* _tmp13_;
318 gboolean _tmp14_ = FALSE;
319 GeeIterator* _tmp15_;
320 gpointer _tmp16_ = NULL;
321 gchar* _tmp17_;
322 GQuark _tmp19_ = 0U;
323 static GQuark _tmp18_label0 = 0;
324 static GQuark _tmp18_label1 = 0;
325 _tmp13_ = iterator;
326 _tmp14_ = gee_iterator_next (_tmp13_);
327 if (!_tmp14_) {
328 break;
329 }
330 _tmp15_ = iterator;
331 _tmp16_ = gee_iterator_get (_tmp15_);
332 _tmp17_ = (gchar*) _tmp16_;
333 _tmp19_ = (NULL == _tmp17_) ? 0 : g_quark_from_string (_tmp17_);
334 g_free (_tmp17_);
335 if (_tmp19_ == ((0 != _tmp18_label0) ? _tmp18_label0 : (_tmp18_label0 = g_quark_from_static_string ("one")))) {
336 switch (0) {
337 default:
338 {
339 gboolean _tmp20_;
340 _tmp20_ = one_found;
341 _vala_assert (!_tmp20_, "! one_found");
342 one_found = TRUE;
343 break;
344 }
345 }
346 } else if (_tmp19_ == ((0 != _tmp18_label1) ? _tmp18_label1 : (_tmp18_label1 = g_quark_from_static_string ("two")))) {
347 switch (0) {
348 default:
349 {
350 gboolean _tmp21_;
351 _tmp21_ = two_found;
352 _vala_assert (!_tmp21_, "! two_found");
353 two_found = TRUE;
354 break;
355 }
356 }
357 } else {
358 switch (0) {
359 default:
360 {
361 g_assert_not_reached ();
362 }
363 }
364 }
365 }
366 _tmp22_ = one_found;
367 _vala_assert (_tmp22_, "one_found");
368 _tmp23_ = two_found;
369 _vala_assert (_tmp23_, "two_found");
370 _tmp24_ = iterator;
371 _tmp25_ = gee_iterator_has_next (_tmp24_);
372 _vala_assert (!_tmp25_, "! iterator.has_next ()");
373 _tmp26_ = iterator;
374 _tmp27_ = gee_iterator_next (_tmp26_);
375 _vala_assert (!_tmp27_, "! iterator.next ()");
376 _tmp28_ = iterator;
377 _tmp29_ = gee_iterator_first (_tmp28_);
378 _vala_assert (_tmp29_, "iterator.first ()");
379 _tmp30_ = g_test_trap_fork ((guint64) 0, G_TEST_TRAP_SILENCE_STDOUT | G_TEST_TRAP_SILENCE_STDERR);
380 if (_tmp30_) {
381 GeeIterator* _tmp31_;
382 _tmp31_ = iterator;
383 gee_iterator_remove (_tmp31_);
384 exit (0);
385 }
386 g_test_trap_assert_failed ();
387 _tmp32_ = self->ro_collection;
388 _tmp33_ = gee_collection_get_size (_tmp32_);
389 _tmp34_ = _tmp33_;
390 _vala_assert (_tmp34_ == 2, "ro_collection.size == 2");
391 _tmp35_ = self->ro_collection;
392 _tmp36_ = gee_collection_contains (_tmp35_, "one");
393 _vala_assert (_tmp36_, "ro_collection.contains (\"one\")");
394 _tmp37_ = self->ro_collection;
395 _tmp38_ = gee_collection_contains (_tmp37_, "two");
396 _vala_assert (_tmp38_, "ro_collection.contains (\"two\")");
397 _g_object_unref0 (iterator);
398 }
399
400
read_only_collection_tests_test_immutable(ReadOnlyCollectionTests * self)401 void read_only_collection_tests_test_immutable (ReadOnlyCollectionTests* self) {
402 GeeCollection* _tmp0_;
403 gboolean _tmp1_ = FALSE;
404 GeeCollection* _tmp2_;
405 gint _tmp3_;
406 gint _tmp4_;
407 GeeCollection* _tmp5_;
408 gboolean _tmp6_ = FALSE;
409 GeeArrayList* _tmp7_;
410 GeeCollection* dummy;
411 GeeCollection* _tmp8_;
412 gboolean _tmp9_ = FALSE;
413 GeeCollection* _tmp10_;
414 gboolean _tmp11_ = FALSE;
415 gboolean _tmp12_ = FALSE;
416 GeeCollection* _tmp15_;
417 gint _tmp16_;
418 gint _tmp17_;
419 GeeCollection* _tmp18_;
420 gboolean _tmp19_ = FALSE;
421 gboolean _tmp20_ = FALSE;
422 GeeCollection* _tmp22_;
423 gint _tmp23_;
424 gint _tmp24_;
425 GeeCollection* _tmp25_;
426 gboolean _tmp26_ = FALSE;
427 gboolean _tmp27_ = FALSE;
428 GeeCollection* _tmp30_;
429 gint _tmp31_;
430 gint _tmp32_;
431 GeeCollection* _tmp33_;
432 gboolean _tmp34_ = FALSE;
433 gboolean _tmp35_ = FALSE;
434 GeeCollection* _tmp39_;
435 gint _tmp40_;
436 gint _tmp41_;
437 GeeCollection* _tmp42_;
438 gboolean _tmp43_ = FALSE;
439 gboolean _tmp44_ = FALSE;
440 GeeCollection* _tmp48_;
441 gint _tmp49_;
442 gint _tmp50_;
443 GeeCollection* _tmp51_;
444 gboolean _tmp52_ = FALSE;
445 GeeCollection* _tmp53_;
446 gboolean _tmp54_ = FALSE;
447 gboolean _tmp55_ = FALSE;
448 GeeCollection* _tmp59_;
449 gint _tmp60_;
450 gint _tmp61_;
451 GeeCollection* _tmp62_;
452 gboolean _tmp63_ = FALSE;
453 g_return_if_fail (self != NULL);
454 _tmp0_ = self->test_collection;
455 _tmp1_ = gee_collection_add (_tmp0_, "one");
456 _vala_assert (_tmp1_, "test_collection.add (\"one\")");
457 _tmp2_ = self->ro_collection;
458 _tmp3_ = gee_collection_get_size (_tmp2_);
459 _tmp4_ = _tmp3_;
460 _vala_assert (_tmp4_ == 1, "ro_collection.size == 1");
461 _tmp5_ = self->ro_collection;
462 _tmp6_ = gee_collection_contains (_tmp5_, "one");
463 _vala_assert (_tmp6_, "ro_collection.contains (\"one\")");
464 _tmp7_ = gee_array_list_new (G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, g_free, NULL);
465 dummy = (GeeCollection*) _tmp7_;
466 _tmp8_ = dummy;
467 _tmp9_ = gee_collection_add (_tmp8_, "one");
468 _vala_assert (_tmp9_, "dummy.add (\"one\")");
469 _tmp10_ = dummy;
470 _tmp11_ = gee_collection_add (_tmp10_, "two");
471 _vala_assert (_tmp11_, "dummy.add (\"two\")");
472 _tmp12_ = g_test_trap_fork ((guint64) 0, G_TEST_TRAP_SILENCE_STDOUT | G_TEST_TRAP_SILENCE_STDERR);
473 if (_tmp12_) {
474 GeeCollection* _tmp13_;
475 gboolean _tmp14_ = FALSE;
476 _tmp13_ = self->ro_collection;
477 _tmp14_ = gee_collection_add (_tmp13_, "two");
478 _vala_assert (_tmp14_, "ro_collection.add (\"two\")");
479 exit (0);
480 }
481 g_test_trap_assert_failed ();
482 _tmp15_ = self->ro_collection;
483 _tmp16_ = gee_collection_get_size (_tmp15_);
484 _tmp17_ = _tmp16_;
485 _vala_assert (_tmp17_ == 1, "ro_collection.size == 1");
486 _tmp18_ = self->ro_collection;
487 _tmp19_ = gee_collection_contains (_tmp18_, "one");
488 _vala_assert (_tmp19_, "ro_collection.contains (\"one\")");
489 _tmp20_ = g_test_trap_fork ((guint64) 0, G_TEST_TRAP_SILENCE_STDOUT | G_TEST_TRAP_SILENCE_STDERR);
490 if (_tmp20_) {
491 GeeCollection* _tmp21_;
492 _tmp21_ = self->ro_collection;
493 gee_collection_clear (_tmp21_);
494 exit (0);
495 }
496 g_test_trap_assert_failed ();
497 _tmp22_ = self->ro_collection;
498 _tmp23_ = gee_collection_get_size (_tmp22_);
499 _tmp24_ = _tmp23_;
500 _vala_assert (_tmp24_ == 1, "ro_collection.size == 1");
501 _tmp25_ = self->ro_collection;
502 _tmp26_ = gee_collection_contains (_tmp25_, "one");
503 _vala_assert (_tmp26_, "ro_collection.contains (\"one\")");
504 _tmp27_ = g_test_trap_fork ((guint64) 0, G_TEST_TRAP_SILENCE_STDOUT | G_TEST_TRAP_SILENCE_STDERR);
505 if (_tmp27_) {
506 GeeCollection* _tmp28_;
507 gboolean _tmp29_ = FALSE;
508 _tmp28_ = self->ro_collection;
509 _tmp29_ = gee_collection_remove (_tmp28_, "one");
510 _vala_assert (_tmp29_, "ro_collection.remove (\"one\")");
511 exit (0);
512 }
513 g_test_trap_assert_failed ();
514 _tmp30_ = self->ro_collection;
515 _tmp31_ = gee_collection_get_size (_tmp30_);
516 _tmp32_ = _tmp31_;
517 _vala_assert (_tmp32_ == 1, "ro_collection.size == 1");
518 _tmp33_ = self->ro_collection;
519 _tmp34_ = gee_collection_contains (_tmp33_, "one");
520 _vala_assert (_tmp34_, "ro_collection.contains (\"one\")");
521 _tmp35_ = g_test_trap_fork ((guint64) 0, G_TEST_TRAP_SILENCE_STDOUT | G_TEST_TRAP_SILENCE_STDERR);
522 if (_tmp35_) {
523 GeeCollection* _tmp36_;
524 GeeCollection* _tmp37_;
525 gboolean _tmp38_ = FALSE;
526 _tmp36_ = self->ro_collection;
527 _tmp37_ = dummy;
528 _tmp38_ = gee_collection_add_all (_tmp36_, _tmp37_);
529 _vala_assert (_tmp38_, "ro_collection.add_all (dummy)");
530 exit (0);
531 }
532 g_test_trap_assert_failed ();
533 _tmp39_ = self->ro_collection;
534 _tmp40_ = gee_collection_get_size (_tmp39_);
535 _tmp41_ = _tmp40_;
536 _vala_assert (_tmp41_ == 1, "ro_collection.size == 1");
537 _tmp42_ = self->ro_collection;
538 _tmp43_ = gee_collection_contains (_tmp42_, "one");
539 _vala_assert (_tmp43_, "ro_collection.contains (\"one\")");
540 _tmp44_ = g_test_trap_fork ((guint64) 0, G_TEST_TRAP_SILENCE_STDOUT | G_TEST_TRAP_SILENCE_STDERR);
541 if (_tmp44_) {
542 GeeCollection* _tmp45_;
543 GeeCollection* _tmp46_;
544 gboolean _tmp47_ = FALSE;
545 _tmp45_ = self->ro_collection;
546 _tmp46_ = dummy;
547 _tmp47_ = gee_collection_remove_all (_tmp45_, _tmp46_);
548 _vala_assert (_tmp47_, "ro_collection.remove_all (dummy)");
549 exit (0);
550 }
551 g_test_trap_assert_failed ();
552 _tmp48_ = self->ro_collection;
553 _tmp49_ = gee_collection_get_size (_tmp48_);
554 _tmp50_ = _tmp49_;
555 _vala_assert (_tmp50_ == 1, "ro_collection.size == 1");
556 _tmp51_ = self->ro_collection;
557 _tmp52_ = gee_collection_contains (_tmp51_, "one");
558 _vala_assert (_tmp52_, "ro_collection.contains (\"one\")");
559 _tmp53_ = dummy;
560 _tmp54_ = gee_collection_remove (_tmp53_, "one");
561 _vala_assert (_tmp54_, "dummy.remove (\"one\")");
562 _tmp55_ = g_test_trap_fork ((guint64) 0, G_TEST_TRAP_SILENCE_STDOUT | G_TEST_TRAP_SILENCE_STDERR);
563 if (_tmp55_) {
564 GeeCollection* _tmp56_;
565 GeeCollection* _tmp57_;
566 gboolean _tmp58_ = FALSE;
567 _tmp56_ = self->ro_collection;
568 _tmp57_ = dummy;
569 _tmp58_ = gee_collection_retain_all (_tmp56_, _tmp57_);
570 _vala_assert (_tmp58_, "ro_collection.retain_all (dummy)");
571 exit (0);
572 }
573 g_test_trap_assert_failed ();
574 _tmp59_ = self->ro_collection;
575 _tmp60_ = gee_collection_get_size (_tmp59_);
576 _tmp61_ = _tmp60_;
577 _vala_assert (_tmp61_ == 1, "ro_collection.size == 1");
578 _tmp62_ = self->ro_collection;
579 _tmp63_ = gee_collection_contains (_tmp62_, "one");
580 _vala_assert (_tmp63_, "ro_collection.contains (\"one\")");
581 _g_object_unref0 (dummy);
582 }
583
584
read_only_collection_tests_test_accurate_view(ReadOnlyCollectionTests * self)585 void read_only_collection_tests_test_accurate_view (ReadOnlyCollectionTests* self) {
586 GeeArrayList* _tmp0_;
587 GeeCollection* dummy;
588 gboolean _tmp1_ = FALSE;
589 gboolean _tmp2_ = FALSE;
590 GeeCollection* _tmp3_;
591 GType _tmp4_;
592 GType _tmp5_;
593 GeeCollection* _tmp6_;
594 gint _tmp7_;
595 gint _tmp8_;
596 GeeCollection* _tmp9_;
597 gboolean _tmp10_;
598 gboolean _tmp11_;
599 GeeCollection* _tmp12_;
600 gboolean _tmp13_ = FALSE;
601 GeeCollection* _tmp14_;
602 gboolean _tmp15_ = FALSE;
603 GeeCollection* _tmp16_;
604 gint _tmp17_;
605 gint _tmp18_;
606 GeeCollection* _tmp19_;
607 gboolean _tmp20_;
608 gboolean _tmp21_;
609 GeeCollection* _tmp22_;
610 gboolean _tmp23_ = FALSE;
611 GeeCollection* _tmp24_;
612 gboolean _tmp25_ = FALSE;
613 GeeCollection* _tmp26_;
614 gint _tmp27_;
615 gint _tmp28_;
616 GeeCollection* _tmp29_;
617 gboolean _tmp30_;
618 gboolean _tmp31_;
619 GeeCollection* _tmp32_;
620 gboolean _tmp33_ = FALSE;
621 GeeCollection* _tmp34_;
622 gboolean _tmp35_ = FALSE;
623 GeeCollection* _tmp36_;
624 gboolean _tmp37_ = FALSE;
625 GeeCollection* _tmp38_;
626 gboolean _tmp39_ = FALSE;
627 GeeCollection* _tmp40_;
628 gint _tmp41_;
629 gint _tmp42_;
630 GeeCollection* _tmp43_;
631 gboolean _tmp44_;
632 gboolean _tmp45_;
633 GeeCollection* _tmp46_;
634 gboolean _tmp47_ = FALSE;
635 GeeCollection* _tmp48_;
636 gboolean _tmp49_ = FALSE;
637 GeeCollection* _tmp50_;
638 gboolean _tmp51_ = FALSE;
639 GeeCollection* _tmp52_;
640 GeeCollection* _tmp53_;
641 gint _tmp54_;
642 gint _tmp55_;
643 GeeCollection* _tmp56_;
644 gboolean _tmp57_;
645 gboolean _tmp58_;
646 GeeCollection* _tmp59_;
647 gboolean _tmp60_ = FALSE;
648 GeeCollection* _tmp61_;
649 gboolean _tmp62_ = FALSE;
650 g_return_if_fail (self != NULL);
651 _tmp0_ = gee_array_list_new (G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, g_free, NULL);
652 dummy = (GeeCollection*) _tmp0_;
653 _tmp1_ = gee_collection_add (dummy, "one");
654 _vala_assert (_tmp1_, "dummy.add (\"one\")");
655 _tmp2_ = gee_collection_add (dummy, "two");
656 _vala_assert (_tmp2_, "dummy.add (\"two\")");
657 _tmp3_ = self->ro_collection;
658 _tmp4_ = gee_iterable_get_element_type ((GeeIterable*) _tmp3_);
659 _tmp5_ = _tmp4_;
660 _vala_assert (_tmp5_ == G_TYPE_STRING, "ro_collection.element_type == typeof (string)");
661 _tmp6_ = self->ro_collection;
662 _tmp7_ = gee_collection_get_size (_tmp6_);
663 _tmp8_ = _tmp7_;
664 _vala_assert (_tmp8_ == 0, "ro_collection.size == 0");
665 _tmp9_ = self->ro_collection;
666 _tmp10_ = gee_collection_get_is_empty (_tmp9_);
667 _tmp11_ = _tmp10_;
668 _vala_assert (_tmp11_, "ro_collection.is_empty");
669 _tmp12_ = self->ro_collection;
670 _tmp13_ = gee_collection_contains (_tmp12_, "one");
671 _vala_assert (!_tmp13_, "! ro_collection.contains (\"one\")");
672 _tmp14_ = self->test_collection;
673 _tmp15_ = gee_collection_add (_tmp14_, "one");
674 _vala_assert (_tmp15_, "test_collection.add (\"one\")");
675 _tmp16_ = self->ro_collection;
676 _tmp17_ = gee_collection_get_size (_tmp16_);
677 _tmp18_ = _tmp17_;
678 _vala_assert (_tmp18_ == 1, "ro_collection.size == 1");
679 _tmp19_ = self->ro_collection;
680 _tmp20_ = gee_collection_get_is_empty (_tmp19_);
681 _tmp21_ = _tmp20_;
682 _vala_assert (!_tmp21_, "! ro_collection.is_empty");
683 _tmp22_ = self->ro_collection;
684 _tmp23_ = gee_collection_contains (_tmp22_, "one");
685 _vala_assert (_tmp23_, "ro_collection.contains (\"one\")");
686 _tmp24_ = self->test_collection;
687 _tmp25_ = gee_collection_add (_tmp24_, "two");
688 _vala_assert (_tmp25_, "test_collection.add (\"two\")");
689 _tmp26_ = self->ro_collection;
690 _tmp27_ = gee_collection_get_size (_tmp26_);
691 _tmp28_ = _tmp27_;
692 _vala_assert (_tmp28_ == 2, "ro_collection.size == 2");
693 _tmp29_ = self->ro_collection;
694 _tmp30_ = gee_collection_get_is_empty (_tmp29_);
695 _tmp31_ = _tmp30_;
696 _vala_assert (!_tmp31_, "! ro_collection.is_empty");
697 _tmp32_ = self->ro_collection;
698 _tmp33_ = gee_collection_contains (_tmp32_, "one");
699 _vala_assert (_tmp33_, "ro_collection.contains (\"one\")");
700 _tmp34_ = self->ro_collection;
701 _tmp35_ = gee_collection_contains (_tmp34_, "two");
702 _vala_assert (_tmp35_, "ro_collection.contains (\"two\")");
703 _tmp36_ = self->ro_collection;
704 _tmp37_ = gee_collection_contains_all (_tmp36_, dummy);
705 _vala_assert (_tmp37_, "ro_collection.contains_all (dummy)");
706 _tmp38_ = self->test_collection;
707 _tmp39_ = gee_collection_remove (_tmp38_, "one");
708 _vala_assert (_tmp39_, "test_collection.remove (\"one\")");
709 _tmp40_ = self->ro_collection;
710 _tmp41_ = gee_collection_get_size (_tmp40_);
711 _tmp42_ = _tmp41_;
712 _vala_assert (_tmp42_ == 1, "ro_collection.size == 1");
713 _tmp43_ = self->ro_collection;
714 _tmp44_ = gee_collection_get_is_empty (_tmp43_);
715 _tmp45_ = _tmp44_;
716 _vala_assert (!_tmp45_, "! ro_collection.is_empty");
717 _tmp46_ = self->ro_collection;
718 _tmp47_ = gee_collection_contains (_tmp46_, "one");
719 _vala_assert (!_tmp47_, "! ro_collection.contains (\"one\")");
720 _tmp48_ = self->ro_collection;
721 _tmp49_ = gee_collection_contains (_tmp48_, "two");
722 _vala_assert (_tmp49_, "ro_collection.contains (\"two\")");
723 _tmp50_ = self->ro_collection;
724 _tmp51_ = gee_collection_contains_all (_tmp50_, dummy);
725 _vala_assert (!_tmp51_, "! ro_collection.contains_all (dummy)");
726 _tmp52_ = self->test_collection;
727 gee_collection_clear (_tmp52_);
728 _tmp53_ = self->ro_collection;
729 _tmp54_ = gee_collection_get_size (_tmp53_);
730 _tmp55_ = _tmp54_;
731 _vala_assert (_tmp55_ == 0, "ro_collection.size == 0");
732 _tmp56_ = self->ro_collection;
733 _tmp57_ = gee_collection_get_is_empty (_tmp56_);
734 _tmp58_ = _tmp57_;
735 _vala_assert (_tmp58_, "ro_collection.is_empty");
736 _tmp59_ = self->ro_collection;
737 _tmp60_ = gee_collection_contains (_tmp59_, "one");
738 _vala_assert (!_tmp60_, "! ro_collection.contains (\"one\")");
739 _tmp61_ = self->ro_collection;
740 _tmp62_ = gee_collection_contains (_tmp61_, "two");
741 _vala_assert (!_tmp62_, "! ro_collection.contains (\"two\")");
742 _g_object_unref0 (dummy);
743 }
744
745
read_only_collection_tests_class_init(ReadOnlyCollectionTestsClass * klass)746 static void read_only_collection_tests_class_init (ReadOnlyCollectionTestsClass * klass) {
747 read_only_collection_tests_parent_class = g_type_class_peek_parent (klass);
748 GEE_TEST_CASE_CLASS (klass)->set_up = read_only_collection_tests_real_set_up;
749 GEE_TEST_CASE_CLASS (klass)->tear_down = read_only_collection_tests_real_tear_down;
750 READ_ONLY_COLLECTION_TESTS_CLASS (klass)->get_ro_view = read_only_collection_tests_real_get_ro_view;
751 G_OBJECT_CLASS (klass)->finalize = read_only_collection_tests_finalize;
752 }
753
754
read_only_collection_tests_instance_init(ReadOnlyCollectionTests * self)755 static void read_only_collection_tests_instance_init (ReadOnlyCollectionTests * self) {
756 }
757
758
read_only_collection_tests_finalize(GObject * obj)759 static void read_only_collection_tests_finalize (GObject* obj) {
760 ReadOnlyCollectionTests * self;
761 self = G_TYPE_CHECK_INSTANCE_CAST (obj, TYPE_READ_ONLY_COLLECTION_TESTS, ReadOnlyCollectionTests);
762 _g_object_unref0 (self->test_collection);
763 _g_object_unref0 (self->ro_collection);
764 G_OBJECT_CLASS (read_only_collection_tests_parent_class)->finalize (obj);
765 }
766
767
read_only_collection_tests_get_type(void)768 GType read_only_collection_tests_get_type (void) {
769 static volatile gsize read_only_collection_tests_type_id__volatile = 0;
770 if (g_once_init_enter (&read_only_collection_tests_type_id__volatile)) {
771 static const GTypeInfo g_define_type_info = { sizeof (ReadOnlyCollectionTestsClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) read_only_collection_tests_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (ReadOnlyCollectionTests), 0, (GInstanceInitFunc) read_only_collection_tests_instance_init, NULL };
772 GType read_only_collection_tests_type_id;
773 read_only_collection_tests_type_id = g_type_register_static (GEE_TYPE_TEST_CASE, "ReadOnlyCollectionTests", &g_define_type_info, 0);
774 g_once_init_leave (&read_only_collection_tests_type_id__volatile, read_only_collection_tests_type_id);
775 }
776 return read_only_collection_tests_type_id__volatile;
777 }
778
779
780
781