summaryrefslogtreecommitdiff
path: root/src/tests/eo/suite/eo_test_call_errors.c
blob: 7e00fc15297ab1bbfa16d922a59ae81ad528f850 (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
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif

#include <stdio.h>

#include "Eo.h"
#include "eo_suite.h"
#include "eo_error_msgs.h"
#include "eo_test_class_simple.h"

static struct log_ctx ctx;

START_TEST(eo_pure_virtual_fct_call)
{
   eo_init();
   eina_log_print_cb_set(eo_test_print_cb, &ctx);

   Eo *obj = eo_add(SIMPLE_CLASS, NULL);
   fail_if(!obj);

   TEST_EO_ERROR("_eo_call_resolve", "in %s:%d: you called a pure virtual func '%s' (%d) of class '%s'.");
   eo_do(obj, simple_pure_virtual());
   fail_unless(ctx.did);

   eo_unref(obj);
   eina_log_print_cb_set(eina_log_print_cb_stderr, NULL);
   eo_shutdown();
}
END_TEST

START_TEST(eo_api_not_implemented_call)
{
   eo_init();
   eina_log_print_cb_set(eo_test_print_cb, &ctx);

   Eo *obj = eo_add(SIMPLE_CLASS, NULL);
   fail_if(!obj);

   TEST_EO_ERROR("_eo_api_op_id_get", "in %s:%d: unable to resolve %s api func '%s' %p in class '%s'.");
   eo_do(obj, simple_no_implementation());
   fail_unless(ctx.did);

   eo_unref(obj);
   eina_log_print_cb_set(eina_log_print_cb_stderr, NULL);
   eo_shutdown();
}
END_TEST

START_TEST(eo_op_not_found_in_super)
{
   eo_init();
   eina_log_print_cb_set(eo_test_print_cb, &ctx);

   Eo *obj = eo_add(SIMPLE_CLASS, NULL);
   fail_if(!obj);

   TEST_EO_ERROR("_eo_call_resolve", "in %s:%d: func '%s' (%d) could not be resolved for class '%s' for super of '%s'.");
   eo_do_super(obj, SIMPLE_CLASS, simple_a_set(10));
   fail_unless(ctx.did);

   eo_unref(obj);
   eina_log_print_cb_set(eina_log_print_cb_stderr, NULL);
   eo_shutdown();
}
END_TEST

void eo_test_call_errors(TCase *tc)
{
   tcase_add_test(tc, eo_pure_virtual_fct_call);
   tcase_add_test(tc, eo_api_not_implemented_call);
   tcase_add_test(tc, eo_op_not_found_in_super);
}