summaryrefslogtreecommitdiff
path: root/src/tests/eo/constructors/constructors_main.c
blob: 5844e466241e23eb2dd5c555ee5300b4eceb3170 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif

#include "Eo.h"
#include "constructors_simple.h"
#include "constructors_simple2.h"
#include "constructors_simple3.h"
#include "constructors_simple4.h"
#include "constructors_simple5.h"
#include "constructors_simple6.h"
#include "constructors_simple7.h"
#include "constructors_mixin.h"

#include "../eunit_tests.h"

int my_init_count = 0;

int
main(int argc, char *argv[])
{
   int ret = 0;
   (void) argc;
   (void) argv;
   eo_init();

   Eo *obj = eo_add(SIMPLE_CLASS, NULL);

   fail_if(my_init_count != 2);

   simple_a_set(obj, 1);
   simple_b_set(obj, 2);

   int a = 0, b = 0;
   a = simple_a_get(obj);
   b = simple_b_get(obj);
   mixin_add_and_print(obj, 5);
   fail_if(a != 1);
   fail_if(b != 2);

   eo_unref(obj);

   fail_if(my_init_count != 0);

   obj = eo_add(SIMPLE2_CLASS, NULL);
   fail_if(obj);

   obj = eo_add(SIMPLE3_CLASS, NULL);
   fail_if(obj);

   my_init_count = 0;
   obj = eo_add(SIMPLE4_CLASS, NULL);

   fail_if(my_init_count != 2);

   eo_unref(obj);

   fail_if(my_init_count != 0);

   obj = eo_add(SIMPLE5_CLASS, NULL);
   fail_if(!obj);
   eo_unref(obj);

   obj = eo_add(SIMPLE6_CLASS, NULL);
   fail_if(!obj);
   eo_unref(obj);

   obj = eo_add(SIMPLE7_CLASS, NULL);
   fail_if(obj);

   my_init_count = 0;
   obj = eo_add(SIMPLE_CLASS, NULL);
   fail_if(!obj);
   fail_if(my_init_count != 2);
   a = simple_a_get(obj);
   fail_if(a != 0);

   my_init_count = 0;
   obj = eo_add(SIMPLE_CLASS, NULL, simple_a_set(eoid, 7));
   fail_if(!obj);
   fail_if(my_init_count != 2);
   a = simple_a_get(obj);
   fail_if(a != 7);

   my_init_count = 0;
   obj = eo_add(SIMPLE_CLASS, NULL, simple_b_set(eoid, 6), simple_a_set(eoid, -1), b = simple_b_get(eoid));
   fail_if(obj);
   fail_if(b != 6);
   fail_if(my_init_count != 0);

   eo_unref(obj);

   eo_shutdown();
   return ret;
}