Eo: Added some negative refcount tests (with manual_free).
[profile/ivi/eobj.git] / src / tests / eo_suite / eo_test_general.c
1 #ifdef HAVE_CONFIG_H
2 # include "config.h"
3 #endif
4
5 #include <stdio.h>
6
7 #include "eo_suite.h"
8 #include "Eo.h"
9
10 #include "class_simple.h"
11
12 START_TEST(eo_simple)
13 {
14    eo_init();
15    Eo *obj = eo_add(EO_BASE_CLASS, NULL);
16    fail_if(obj);
17
18    obj = eo_add(SIMPLE_CLASS, NULL);
19    fail_if(!obj);
20    eo_do(obj, eo_constructor());
21    eo_do(obj, eo_destructor());
22    eo_unref(obj);
23
24    eo_shutdown();
25 }
26 END_TEST
27
28 START_TEST(eo_data_fetch)
29 {
30    eo_init();
31
32    /* Usually should be const, not const only for the test... */
33    static Eo_Class_Description class_desc = {
34         EO_VERSION,
35         "Simple2",
36         EO_CLASS_TYPE_REGULAR,
37         EO_CLASS_DESCRIPTION_OPS(NULL, NULL, 0),
38         NULL,
39         10,
40         NULL,
41         NULL
42    };
43
44    const Eo_Class *klass = eo_class_new(&class_desc, EO_BASE_CLASS, NULL);
45    fail_if(!klass);
46
47    Eo *obj = eo_add(klass, NULL);
48    fail_if(!obj);
49 #ifndef NDEBUG
50    fail_if(eo_data_get(obj, SIMPLE_CLASS));
51 #endif
52    eo_unref(obj);
53
54    class_desc.data_size = 0;
55    klass = eo_class_new(&class_desc, EO_BASE_CLASS, NULL);
56    fail_if(!klass);
57
58    obj = eo_add(klass, NULL);
59    fail_if(!obj);
60    fail_if(eo_data_get(obj, klass));
61    eo_unref(obj);
62
63    eo_shutdown();
64 }
65 END_TEST
66
67 START_TEST(eo_isa_tests)
68 {
69    eo_init();
70
71    const Eo_Class *klass, *iface, *mixin;
72
73      {
74         /* Usually should be const, not const only for the test... */
75         static Eo_Class_Description class_desc = {
76              EO_VERSION,
77              "Iface",
78              EO_CLASS_TYPE_INTERFACE,
79              EO_CLASS_DESCRIPTION_OPS(NULL, NULL, 0),
80              NULL,
81              0,
82              NULL,
83              NULL
84         };
85
86         iface = eo_class_new(&class_desc, NULL, NULL);
87         fail_if(!iface);
88      }
89
90      {
91         /* Usually should be const, not const only for the test... */
92         static Eo_Class_Description class_desc = {
93              EO_VERSION,
94              "Mixin",
95              EO_CLASS_TYPE_MIXIN,
96              EO_CLASS_DESCRIPTION_OPS(NULL, NULL, 0),
97              NULL,
98              0,
99              NULL,
100              NULL
101         };
102
103         mixin = eo_class_new(&class_desc, NULL, NULL);
104         fail_if(!mixin);
105      }
106
107      {
108         /* Usually should be const, not const only for the test... */
109         static Eo_Class_Description class_desc = {
110              EO_VERSION,
111              "Simple2",
112              EO_CLASS_TYPE_REGULAR,
113              EO_CLASS_DESCRIPTION_OPS(NULL, NULL, 0),
114              NULL,
115              10,
116              NULL,
117              NULL
118         };
119
120         klass = eo_class_new(&class_desc, EO_BASE_CLASS, iface, mixin, NULL);
121         fail_if(!klass);
122      }
123
124    Eo *obj = eo_add(klass, NULL);
125    fail_if(!obj);
126    fail_if(eo_isa(obj, SIMPLE_CLASS));
127    fail_if(!eo_isa(obj, iface));
128    fail_if(!eo_isa(obj, mixin));
129    fail_if(!eo_isa(obj, klass));
130    fail_if(!eo_isa(obj, EO_BASE_CLASS));
131    eo_unref(obj);
132
133    obj = eo_add(SIMPLE_CLASS, NULL);
134    fail_if(!obj);
135    fail_if(eo_isa(obj, klass));
136    fail_if(eo_isa(obj, iface));
137    fail_if(eo_isa(obj, mixin));
138    fail_if(!eo_isa(obj, SIMPLE_CLASS));
139    fail_if(!eo_isa(obj, EO_BASE_CLASS));
140    eo_unref(obj);
141
142    eo_shutdown();
143 }
144 END_TEST
145
146
147 START_TEST(eo_composite_tests)
148 {
149    eo_init();
150
151    Eo *obj = eo_add(SIMPLE_CLASS, NULL);
152    fail_if(!obj);
153    Eo *obj2 = eo_add(SIMPLE_CLASS, NULL);
154    fail_if(!obj2);
155
156    eo_composite_attach(obj2, obj);
157    eo_parent_set(obj2, NULL);
158    fail_if(eo_composite_is(obj2));
159
160    eo_unref(obj2);
161    eo_unref(obj);
162
163    eo_shutdown();
164 }
165 END_TEST
166
167 static Eina_Bool _man_should_con = EINA_TRUE;
168 static Eina_Bool _man_should_des = EINA_TRUE;
169
170 static void
171 _man_con(Eo *obj, void *data EINA_UNUSED, va_list *list EINA_UNUSED)
172 {
173    if (_man_should_con)
174       eo_manual_free_set(obj, EINA_TRUE);
175    eo_do_super(obj, eo_constructor());
176 }
177
178 static void
179 _man_des(Eo *obj, void *data EINA_UNUSED, va_list *list EINA_UNUSED)
180 {
181    eo_do_super(obj, eo_destructor());
182    if (_man_should_des)
183       eo_manual_free_set(obj, EINA_FALSE);
184 }
185
186
187 static void
188 _man_class_constructor(Eo_Class *klass)
189 {
190    const Eo_Op_Func_Description func_desc[] = {
191         EO_OP_FUNC(EO_BASE_ID(EO_BASE_SUB_ID_CONSTRUCTOR), _man_con),
192         EO_OP_FUNC(EO_BASE_ID(EO_BASE_SUB_ID_DESTRUCTOR), _man_des),
193         EO_OP_FUNC(EO_BASE_ID(EO_BASE_SUB_ID_DESTRUCTOR), _man_des),
194         EO_OP_FUNC_SENTINEL
195    };
196
197    eo_class_funcs_set(klass, func_desc);
198 }
199
200 START_TEST(eo_man_free)
201 {
202    eo_init();
203
204    /* Usually should be const, not const only for the test... */
205    static Eo_Class_Description class_desc = {
206         EO_VERSION,
207         "Simple2",
208         EO_CLASS_TYPE_REGULAR,
209         EO_CLASS_DESCRIPTION_OPS(NULL, NULL, 0),
210         NULL,
211         10,
212         _man_class_constructor,
213         NULL
214    };
215
216    const Eo_Class *klass = eo_class_new(&class_desc, EO_BASE_CLASS, NULL);
217    fail_if(!klass);
218
219    Eo *obj = eo_add(klass, NULL);
220    fail_if(!obj);
221    eo_unref(obj);
222
223    obj = eo_add(klass, NULL);
224    fail_if(!obj);
225    eo_manual_free(obj);
226    eo_unref(obj);
227
228    _man_should_des = EINA_FALSE;
229    klass = eo_class_new(&class_desc, EO_BASE_CLASS, NULL);
230    fail_if(!klass);
231
232    obj = eo_add(klass, NULL);
233    fail_if(!obj);
234    eo_manual_free(obj);
235    eo_unref(obj);
236    eo_manual_free(obj);
237
238    obj = eo_add(klass, NULL);
239    fail_if(!obj);
240    eo_unref(obj);
241    eo_manual_free(obj);
242
243    _man_should_con = EINA_FALSE;
244    klass = eo_class_new(&class_desc, EO_BASE_CLASS, NULL);
245    fail_if(!klass);
246
247    obj = eo_add(klass, NULL);
248    fail_if(!obj);
249    eo_manual_free(obj);
250    eo_unref(obj);
251
252    obj = eo_add(klass, NULL);
253    fail_if(!obj);
254    eo_manual_free_set(obj, EINA_TRUE);
255    eo_unref(obj);
256    eo_ref(obj);
257    eo_unref(obj);
258    eo_unref(obj);
259    eo_manual_free(obj);
260
261    obj = eo_add(klass, NULL);
262    fail_if(!obj);
263    eo_manual_free_set(obj, EINA_TRUE);
264    eo_unref(obj);
265    eo_ref(obj);
266    eo_unref(obj);
267    eo_unref(obj);
268    eo_unref(obj);
269    eo_unref(obj);
270    eo_manual_free(obj);
271
272    eo_shutdown();
273 }
274 END_TEST
275
276 START_TEST(eo_refs)
277 {
278    eo_init();
279    Eo *obj = eo_add(SIMPLE_CLASS, NULL);
280    Eo *obj2 = eo_add(SIMPLE_CLASS, NULL);
281    Eo *obj3 = eo_add(SIMPLE_CLASS, NULL);
282
283    eo_xref(obj, obj2);
284    fail_if(eo_ref_get(obj) != 2);
285    eo_xref(obj, obj3);
286    fail_if(eo_ref_get(obj) != 3);
287
288    eo_xunref(obj, obj2);
289    fail_if(eo_ref_get(obj) != 2);
290    eo_xunref(obj, obj3);
291    fail_if(eo_ref_get(obj) != 1);
292
293 #ifndef NDEBUG
294    eo_xunref(obj, obj3);
295    fail_if(eo_ref_get(obj) != 1);
296
297    eo_xref(obj, obj2);
298    fail_if(eo_ref_get(obj) != 2);
299
300    eo_xunref(obj, obj3);
301    fail_if(eo_ref_get(obj) != 2);
302
303    eo_xunref(obj, obj2);
304    fail_if(eo_ref_get(obj) != 1);
305 #endif
306
307    /* Check we don't seg if there's an extra xref. */
308    eo_xref(obj, obj2);
309    eo_unref(obj);
310
311    eo_unref(obj);
312    eo_unref(obj2);
313    eo_unref(obj3);
314
315    /* Check hierarchy */
316    obj = eo_add(SIMPLE_CLASS, NULL);
317    obj2 = eo_add(SIMPLE_CLASS, obj);
318
319    Eo *wref;
320    eo_do(obj2, eo_wref_add(&wref));
321    fail_if(!wref);
322
323    eo_unref(obj2);
324
325    fail_if(!wref); /* Parent is still holding a reference. */
326
327    eo_unref(obj);
328
329    fail_if(wref);
330
331    /* Just check it doesn't seg atm. */
332    obj = eo_add(SIMPLE_CLASS, NULL);
333    eo_ref(obj);
334    eo_unref(obj);
335    eo_unref(obj);
336
337    obj = eo_add(SIMPLE_CLASS, NULL);
338    obj2 = eo_add(SIMPLE_CLASS, obj);
339    eo_unref(obj2);
340    eo_ref(obj2);
341    eo_del(obj2);
342    eo_unref(obj);
343
344    eo_shutdown();
345 }
346 END_TEST
347
348 START_TEST(eo_weak_reference)
349 {
350    eo_init();
351
352    Eo *obj = eo_add(SIMPLE_CLASS, NULL);
353    Eo *obj2 = eo_add(SIMPLE_CLASS, NULL);
354    Eo *wref, *wref2, *wref3;
355    eo_do(obj, eo_wref_add(&wref));
356    fail_if(!wref);
357
358    eo_unref(obj);
359    fail_if(wref);
360
361    obj = eo_add(SIMPLE_CLASS, NULL);
362    eo_do(obj, eo_wref_add(&wref));
363
364    eo_ref(obj);
365    fail_if(!wref);
366
367    eo_unref(obj);
368    fail_if(!wref);
369
370    eo_unref(obj);
371    fail_if(wref);
372
373    obj = eo_add(SIMPLE_CLASS, NULL);
374
375    eo_do(obj, eo_wref_add(&wref));
376    eo_do(obj, eo_wref_del(&wref));
377    fail_if(wref);
378
379    eo_do(obj, eo_wref_add(&wref));
380    eo_do(obj2, eo_wref_del(&wref));
381    fail_if(!wref);
382    eo_wref_del_safe(&wref);
383    fail_if(wref);
384
385    wref = obj;
386    eo_do(obj, eo_wref_del(&wref));
387    fail_if(wref);
388
389    wref = wref2 = wref3 = NULL;
390    eo_do(obj, eo_wref_add(&wref), eo_wref_add(&wref2), eo_wref_add(&wref3));
391    fail_if(!wref);
392    fail_if(!wref2);
393    fail_if(!wref3);
394    eo_do(obj, eo_wref_del(&wref), eo_wref_del(&wref2), eo_wref_del(&wref3));
395    fail_if(wref);
396    fail_if(wref2);
397    fail_if(wref3);
398
399    eo_do(obj, eo_wref_add(&wref2), eo_wref_add(&wref3));
400    wref = obj;
401    eo_do(obj, eo_wref_del(&wref));
402    fail_if(wref);
403    eo_do(obj, eo_wref_del(&wref2), eo_wref_del(&wref3));
404
405    eo_unref(obj);
406    eo_unref(obj2);
407
408
409    eo_shutdown();
410 }
411 END_TEST
412
413 static void
414 _a_set(Eo *obj EINA_UNUSED, void *class_data EINA_UNUSED, va_list *list EINA_UNUSED)
415 {
416    fail_if(EINA_TRUE);
417 }
418
419 static void
420 _op_errors_class_constructor(Eo_Class *klass)
421 {
422    const Eo_Op_Func_Description func_desc[] = {
423         EO_OP_FUNC(SIMPLE_ID(SIMPLE_SUB_ID_LAST), _a_set),
424         EO_OP_FUNC(SIMPLE_ID(SIMPLE_SUB_ID_LAST + 1), _a_set),
425         EO_OP_FUNC(0x0F010111, _a_set),
426         EO_OP_FUNC_SENTINEL
427    };
428
429    eo_class_funcs_set(klass, func_desc);
430 }
431
432 START_TEST(eo_op_errors)
433 {
434    eo_init();
435
436    static const Eo_Class_Description class_desc = {
437         EO_VERSION,
438         "Simple",
439         EO_CLASS_TYPE_REGULAR,
440         EO_CLASS_DESCRIPTION_OPS(NULL, NULL, 0),
441         NULL,
442         0,
443         _op_errors_class_constructor,
444         NULL
445    };
446
447    const Eo_Class *klass = eo_class_new(&class_desc, SIMPLE_CLASS, NULL);
448    fail_if(!klass);
449
450    Eo *obj = eo_add(klass, NULL);
451
452    /* Out of bounds op for a legal class. */
453    fail_if(eo_do(obj, EO_BASE_ID(0x0111)));
454
455    /* Ilegal class. */
456    fail_if(eo_do(obj, 0x0F010111));
457
458    fail_if(eo_ref_get(obj) != 1);
459
460    eo_ref(obj);
461    fail_if(eo_ref_get(obj) != 2);
462
463    eo_ref(obj);
464    fail_if(eo_ref_get(obj) != 3);
465
466    eo_unref(obj);
467    fail_if(eo_ref_get(obj) != 2);
468
469    eo_unref(obj);
470    fail_if(eo_ref_get(obj) != 1);
471
472    eo_unref(obj);
473
474    obj = eo_add(SIMPLE_CLASS, NULL);
475    fail_if(!eo_do(obj, simple_a_print()));
476    fail_if(!eo_do(obj, simple_a_print()));
477    fail_if(!eo_do(obj, simple_a_set(1)));
478    eo_unref(obj);
479
480    eo_shutdown();
481 }
482 END_TEST
483
484 static void
485 _fake_free_func(void *data)
486 {
487    if (!data)
488       return;
489
490    int *a = data;
491    ++*a;
492 }
493
494 START_TEST(eo_generic_data)
495 {
496    eo_init();
497    Eo *obj = eo_add(SIMPLE_CLASS, NULL);
498    void *data;
499
500    eo_do(obj, eo_base_data_set("test1", (void *) 1, NULL));
501    eo_do(obj, eo_base_data_get("test1", &data));
502    fail_if(1 != (int) data);
503    eo_do(obj, eo_base_data_del("test1"));
504    eo_do(obj, eo_base_data_get("test1", &data));
505    fail_if(data);
506
507    eo_do(obj, eo_base_data_set("test1", (void *) 1, NULL));
508    eo_do(obj, eo_base_data_set("test2", (void *) 2, NULL));
509    eo_do(obj, eo_base_data_get("test1", &data));
510    fail_if(1 != (int) data);
511    eo_do(obj, eo_base_data_get("test2", &data));
512    fail_if(2 != (int) data);
513
514    eo_do(obj, eo_base_data_get("test2", &data));
515    fail_if(2 != (int) data);
516    eo_do(obj, eo_base_data_del("test2"));
517    eo_do(obj, eo_base_data_get("test2", &data));
518    fail_if(data);
519
520    eo_do(obj, eo_base_data_get("test1", &data));
521    fail_if(1 != (int) data);
522    eo_do(obj, eo_base_data_del("test1"));
523    eo_do(obj, eo_base_data_get("test1", &data));
524    fail_if(data);
525
526    int a = 0;
527    eo_do(obj, eo_base_data_set("test3", &a, _fake_free_func));
528    eo_do(obj, eo_base_data_get("test3", &data));
529    fail_if(&a != data);
530    eo_do(obj, eo_base_data_get("test3", NULL));
531    eo_do(obj, eo_base_data_del("test3"));
532    fail_if(a != 1);
533
534    a = 0;
535    eo_do(obj, eo_base_data_set("test3", &a, _fake_free_func));
536    eo_do(obj, eo_base_data_set("test3", NULL, _fake_free_func));
537    fail_if(a != 1);
538    a = 0;
539    data = (void *) 123;
540    eo_do(obj, eo_base_data_set(NULL, &a, _fake_free_func));
541    eo_do(obj, eo_base_data_get(NULL, &data));
542    fail_if(data);
543    eo_do(obj, eo_base_data_del(NULL));
544
545    a = 0;
546    eo_do(obj, eo_base_data_set("test3", &a, _fake_free_func));
547    eo_do(obj, eo_base_data_set("test3", NULL, NULL));
548    fail_if(a != 1);
549    eo_do(obj, eo_base_data_set("test3", &a, _fake_free_func));
550
551    eo_unref(obj);
552    fail_if(a != 2);
553
554    eo_shutdown();
555 }
556 END_TEST
557
558 START_TEST(eo_magic_checks)
559 {
560    char _buf[sizeof(long)]; /* Just enough to hold eina magic + a bit more. */
561    char *buf = _buf;
562    eo_init();
563
564    memset(_buf, 1, sizeof(_buf));
565
566    Eo *obj = eo_add(SIMPLE_CLASS, (Eo *) buf);
567    fail_if(obj);
568
569    while (1)
570      {
571         obj = eo_add((Eo_Class *) buf, NULL);
572         fail_if(obj);
573
574         obj = eo_add(SIMPLE_CLASS, NULL);
575         fail_if(!obj);
576
577         fail_if(eo_do((Eo *) buf, EO_NOOP));
578         fail_if(eo_do_super((Eo *) buf, EO_NOOP));
579         fail_if(eo_class_get((Eo *) buf));
580         fail_if(eo_class_name_get((Eo_Class*) buf));
581         eo_class_funcs_set((Eo_Class *) buf, NULL);
582         eo_class_do((Eo_Class *) buf, NULL);
583         eo_class_do_super((Eo_Class *) buf, EO_NOOP);
584
585         fail_if(eo_class_new(NULL, (Eo_Class *) buf), NULL);
586
587         eo_xref(obj, (Eo *) buf);
588         eo_xunref(obj, (Eo *) buf);
589         eo_xref((Eo *) buf, obj);
590         eo_xunref((Eo *) buf, obj);
591
592         eo_ref((Eo *) buf);
593         eo_unref((Eo *) buf);
594         eo_del((Eo *) buf);
595
596         eo_isa((Eo *) buf, SIMPLE_CLASS);
597         eo_isa(obj, (Eo_Class *) buf);
598
599         fail_if(0 != eo_ref_get((Eo *) buf));
600
601         Eo *wref = NULL;
602         eo_do((Eo *) buf, eo_wref_add(&wref));
603         fail_if(wref);
604
605         fail_if(eo_parent_get((Eo *) buf));
606
607         eo_error_set((Eo *) buf);
608
609         fail_if(eo_data_get((Eo *) buf, SIMPLE_CLASS));
610
611         eo_composite_attach((Eo *) buf, obj);
612         eo_composite_attach(obj, (Eo *) buf);
613         eo_composite_detach((Eo *) buf, obj);
614         eo_composite_detach(obj, (Eo *) buf);
615         eo_composite_is((Eo *) buf);
616
617         eo_do(obj, eo_event_callback_forwarder_add(NULL, (Eo *) buf));
618         eo_do(obj, eo_event_callback_forwarder_del(NULL, (Eo *) buf));
619
620         eo_manual_free_set((Eo *) buf, EINA_TRUE);
621         eo_manual_free((Eo *) buf);
622
623         eo_unref(obj);
624
625         if (!buf)
626            break;
627         else
628            buf = NULL;
629      }
630
631    eo_shutdown();
632 }
633 END_TEST
634
635 /* MULTI */
636 static Eo_Op MULTI_BASE_ID;
637 #define MULTI_ID(sub_id) (MULTI_BASE_ID + sub_id)
638 #define multi_a_print() MULTI_ID(MULTI_SUB_ID_A_PRINT)
639 #define multi_class_hi_print() MULTI_ID(MULTI_SUB_ID_CLASS_HI_PRINT)
640
641 static void
642 _a_print(Eo *obj EINA_UNUSED, void *class_data EINA_UNUSED, va_list *list EINA_UNUSED)
643 {
644    printf("Hey\n");
645 }
646
647 static void
648 _class_hi_print(const Eo_Class *klass EINA_UNUSED, va_list *list EINA_UNUSED)
649 {
650    printf("Hi\n");
651 }
652
653 enum {
654      MULTI_SUB_ID_A_PRINT,
655      MULTI_SUB_ID_CLASS_HI_PRINT,
656      MULTI_SUB_ID_LAST
657 };
658
659 static void
660 _eo_multiple_do_class_constructor(Eo_Class *klass)
661 {
662    const Eo_Op_Func_Description func_desc[] = {
663         EO_OP_FUNC(MULTI_ID(MULTI_SUB_ID_A_PRINT), _a_print),
664         EO_OP_FUNC_CLASS(MULTI_ID(MULTI_SUB_ID_CLASS_HI_PRINT), _class_hi_print),
665         EO_OP_FUNC_SENTINEL
666    };
667
668    eo_class_funcs_set(klass, func_desc);
669 }
670
671 static const Eo_Op_Description _eo_multiple_do_op_desc[] = {
672      EO_OP_DESCRIPTION(MULTI_SUB_ID_A_PRINT, "Print property A"),
673      EO_OP_DESCRIPTION_CLASS(MULTI_SUB_ID_CLASS_HI_PRINT, "Print Hi"),
674      EO_OP_DESCRIPTION_SENTINEL
675 };
676
677
678 START_TEST(eo_multiple_do)
679 {
680    eo_init();
681
682    /* Usually should be const, not const only for the test... */
683    static Eo_Class_Description class_desc = {
684         EO_VERSION,
685         "Inherit",
686         EO_CLASS_TYPE_REGULAR,
687         EO_CLASS_DESCRIPTION_OPS(&MULTI_BASE_ID, _eo_multiple_do_op_desc, MULTI_SUB_ID_LAST),
688         NULL,
689         0,
690         _eo_multiple_do_class_constructor,
691         NULL
692    };
693
694    const Eo_Class *klass = eo_class_new(&class_desc, SIMPLE_CLASS, NULL);
695    fail_if(!klass);
696
697    Eo *obj = eo_add(klass, NULL);
698    fail_if(!obj);
699
700    fail_if(!eo_do(obj, simple_a_print(), multi_a_print(), multi_a_print()));
701    fail_if(!eo_class_do(klass, simple_class_hi_print(), multi_class_hi_print(), multi_class_hi_print()));
702
703    eo_unref(obj);
704
705    eo_shutdown();
706 }
707 END_TEST
708
709 START_TEST(eo_add_do_and_custom)
710 {
711    Simple_Public_Data *pd = NULL;
712    Eo *obj = NULL;
713    eo_init();
714
715    obj = eo_add_custom(SIMPLE_CLASS, NULL, eo_constructor());
716    fail_if(!obj);
717    eo_unref(obj);
718
719    obj = eo_add(SIMPLE_CLASS, NULL, simple_a_set(7));
720    fail_if(!obj);
721    pd = eo_data_get(obj, SIMPLE_CLASS);
722    fail_if(pd->a != 7);
723    eo_unref(obj);
724
725    obj = eo_add_custom(SIMPLE_CLASS, NULL, eo_constructor(), simple_a_set(7));
726    fail_if(!obj);
727    pd = eo_data_get(obj, SIMPLE_CLASS);
728    fail_if(pd->a != 7);
729    eo_unref(obj);
730
731    eo_shutdown();
732 }
733 END_TEST
734
735 void eo_test_general(TCase *tc)
736 {
737    tcase_add_test(tc, eo_generic_data);
738    tcase_add_test(tc, eo_op_errors);
739    tcase_add_test(tc, eo_simple);
740    tcase_add_test(tc, eo_weak_reference);
741    tcase_add_test(tc, eo_refs);
742    tcase_add_test(tc, eo_magic_checks);
743    tcase_add_test(tc, eo_data_fetch);
744    tcase_add_test(tc, eo_man_free);
745    tcase_add_test(tc, eo_composite_tests);
746    tcase_add_test(tc, eo_isa_tests);
747    tcase_add_test(tc, eo_multiple_do);
748    tcase_add_test(tc, eo_add_do_and_custom);
749 }