Eobj: Added some more test scenarios.
[profile/ivi/eobj.git] / tests / eobj_test_general.c
1 #ifdef HAVE_CONFIG_H
2 # include "config.h"
3 #endif
4
5 #include <stdio.h>
6
7 #include "eobj_suite.h"
8 #include "Eobj.h"
9
10 #include "class_simple.h"
11
12 START_TEST(eobj_simple)
13 {
14    eobj_init();
15    Eobj *obj = eobj_add(EOBJ_CLASS_BASE, NULL);
16
17    fail_if(obj);
18    eobj_shutdown();
19 }
20 END_TEST
21
22 START_TEST(eobj_op_errors)
23 {
24    eobj_init();
25    Eobj *obj = eobj_add(SIMPLE_CLASS, NULL);
26
27    /* Out of bounds op for a legal class. */
28    fail_if(eobj_do(obj, 0x00010111));
29
30    /* Ilegal class. */
31    fail_if(eobj_do(obj, 0x0F010111));
32
33    fail_if(eobj_ref_get(obj) != 1);
34
35    eobj_ref(obj);
36    fail_if(eobj_ref_get(obj) != 2);
37
38    eobj_ref(obj);
39    fail_if(eobj_ref_get(obj) != 3);
40
41    eobj_unref(obj);
42    fail_if(eobj_ref_get(obj) != 2);
43
44    eobj_unref(obj);
45    fail_if(eobj_ref_get(obj) != 1);
46
47    eobj_unref(obj);
48    eobj_shutdown();
49 }
50 END_TEST
51
52 void eobj_test_general(TCase *tc)
53 {
54    tcase_add_test(tc, eobj_op_errors);
55    tcase_add_test(tc, eobj_simple);
56 }