summaryrefslogtreecommitdiff
path: root/src/tests/function_overrides/main.c
blob: af39c6726597db15a1326e9e046c26524c361a6d (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
#include "Eo.h"
#include "simple.h"
#include "inherit.h"
#include "inherit2.h"
#include "inherit3.h"

#include "../eunit_tests.h"

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

   Eo *obj = eo_add(INHERIT2_CLASS, NULL);

   eo_do(obj, simple_a_set(1));
   Simple_Public_Data *pd = eo_data_get(obj, SIMPLE_CLASS);
   fail_if(pd->a != 2);

   eo_unref(obj);

   obj = eo_add(INHERIT3_CLASS, NULL);

   eo_do(obj, simple_a_set(1));
   pd = eo_data_get(obj, SIMPLE_CLASS);
   fail_if(pd->a != 3);

   eo_unref(obj);

   obj = eo_add(INHERIT2_CLASS, NULL);
   fail_if(!eo_do(obj, inherit2_print()));
   fail_if(!eo_do(obj, inherit2_print(), inherit2_print()));
   eo_unref(obj);

   obj = eo_add(SIMPLE_CLASS, NULL);
   fail_if(eo_do(obj, inherit2_print2()));

   fail_if(eo_do_super(obj, simple_a_print()));

   fail_if(eo_do(obj, simple_class_print()));

   fail_if(!eo_class_do(SIMPLE_CLASS, simple_class_print()));
   fail_if(!eo_class_do(INHERIT_CLASS, simple_class_print()));
   fail_if(!eo_class_do(INHERIT2_CLASS, simple_class_print()));
   fail_if(!eo_class_do(INHERIT3_CLASS, simple_class_print()));

   fail_if(eo_class_do(SIMPLE_CLASS, simple_a_print()));

   eo_do_super(obj, eo_constructor());
   eo_do_super(obj, eo_destructor());

   eo_unref(obj);

   eo_shutdown();
   return 0;
}