forked from enlightenment/efl
parent
d113debcd2
commit
ef994b8163
|
@ -2,6 +2,8 @@
|
||||||
#include "simple.h"
|
#include "simple.h"
|
||||||
#include "comp.h"
|
#include "comp.h"
|
||||||
|
|
||||||
|
#include "../eunit_tests.h"
|
||||||
|
|
||||||
static int cb_called = EINA_FALSE;
|
static int cb_called = EINA_FALSE;
|
||||||
|
|
||||||
static Eina_Bool
|
static Eina_Bool
|
||||||
|
@ -29,18 +31,11 @@ main(int argc, char *argv[])
|
||||||
|
|
||||||
int a;
|
int a;
|
||||||
eobj_do(obj, SIMPLE_A_SET(1));
|
eobj_do(obj, SIMPLE_A_SET(1));
|
||||||
if (!cb_called)
|
fail_if(!cb_called);
|
||||||
{
|
|
||||||
printf("Error! %d\n", __LINE__);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
eobj_do(obj, SIMPLE_A_GET(&a));
|
eobj_do(obj, SIMPLE_A_GET(&a));
|
||||||
if (a != 1)
|
fail_if(a != 1);
|
||||||
{
|
|
||||||
printf("Error! %d\n", __LINE__);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
eobj_unref(obj);
|
eobj_unref(obj);
|
||||||
|
|
||||||
eobj_shutdown();
|
eobj_shutdown();
|
||||||
|
|
|
@ -5,6 +5,8 @@
|
||||||
#include "simple4.h"
|
#include "simple4.h"
|
||||||
#include "mixin.h"
|
#include "mixin.h"
|
||||||
|
|
||||||
|
#include "../eunit_tests.h"
|
||||||
|
|
||||||
int my_init_count = 0;
|
int my_init_count = 0;
|
||||||
|
|
||||||
int
|
int
|
||||||
|
@ -17,11 +19,7 @@ main(int argc, char *argv[])
|
||||||
|
|
||||||
Eobj *obj = eobj_add(SIMPLE_CLASS, NULL);
|
Eobj *obj = eobj_add(SIMPLE_CLASS, NULL);
|
||||||
|
|
||||||
if (my_init_count != 2)
|
fail_if(my_init_count != 2);
|
||||||
{
|
|
||||||
printf("Error! my_init_count == %d\n", my_init_count);
|
|
||||||
ret = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
eobj_do(obj, SIMPLE_A_SET(1), SIMPLE_B_SET(2));
|
eobj_do(obj, SIMPLE_A_SET(1), SIMPLE_B_SET(2));
|
||||||
|
|
||||||
|
@ -30,42 +28,22 @@ main(int argc, char *argv[])
|
||||||
|
|
||||||
eobj_unref(obj);
|
eobj_unref(obj);
|
||||||
|
|
||||||
if (my_init_count != 0)
|
fail_if(my_init_count != 0);
|
||||||
{
|
|
||||||
printf("Error! my_init_count == %d\n", my_init_count);
|
|
||||||
ret = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
obj = eobj_add(SIMPLE2_CLASS, NULL);
|
obj = eobj_add(SIMPLE2_CLASS, NULL);
|
||||||
if (obj)
|
fail_if(obj);
|
||||||
{
|
|
||||||
printf("Error! obj is supposed to be NULL.\n");
|
|
||||||
ret = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
obj = eobj_add(SIMPLE3_CLASS, NULL);
|
obj = eobj_add(SIMPLE3_CLASS, NULL);
|
||||||
if (obj)
|
fail_if(obj);
|
||||||
{
|
|
||||||
printf("Error! obj is supposed to be NULL.\n");
|
|
||||||
ret = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
my_init_count = 0;
|
my_init_count = 0;
|
||||||
obj = eobj_add(SIMPLE4_CLASS, NULL);
|
obj = eobj_add(SIMPLE4_CLASS, NULL);
|
||||||
|
|
||||||
if (my_init_count != 2)
|
fail_if(my_init_count != 2);
|
||||||
{
|
|
||||||
printf("Error! my_init_count == %d\n", my_init_count);
|
|
||||||
ret = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
eobj_unref(obj);
|
eobj_unref(obj);
|
||||||
|
|
||||||
if (my_init_count != 0)
|
fail_if(my_init_count != 0);
|
||||||
{
|
|
||||||
printf("Error! my_init_count == %d\n", my_init_count);
|
|
||||||
ret = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
eobj_shutdown();
|
eobj_shutdown();
|
||||||
return ret;
|
return ret;
|
||||||
|
|
|
@ -0,0 +1,17 @@
|
||||||
|
#ifndef _EUNIT_TESTS_H
|
||||||
|
#define _EUNIT_TESTS_H
|
||||||
|
|
||||||
|
#define _EUNIT_EXIT_CODE 1
|
||||||
|
|
||||||
|
#define fail_if(x) \
|
||||||
|
do { \
|
||||||
|
if (x) \
|
||||||
|
{ \
|
||||||
|
fprintf(stderr, "%s:%d - Failure '%s' is TRUE.", \
|
||||||
|
__FILE__, __LINE__, # x); \
|
||||||
|
exit(_EUNIT_EXIT_CODE); \
|
||||||
|
} \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
|
@ -4,6 +4,8 @@
|
||||||
#include "inherit2.h"
|
#include "inherit2.h"
|
||||||
#include "inherit3.h"
|
#include "inherit3.h"
|
||||||
|
|
||||||
|
#include "../eunit_tests.h"
|
||||||
|
|
||||||
int
|
int
|
||||||
main(int argc, char *argv[])
|
main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
|
@ -15,20 +17,15 @@ main(int argc, char *argv[])
|
||||||
|
|
||||||
eobj_do(obj, SIMPLE_A_SET(1));
|
eobj_do(obj, SIMPLE_A_SET(1));
|
||||||
Simple_Public_Data *pd = eobj_data_get(obj, SIMPLE_CLASS);
|
Simple_Public_Data *pd = eobj_data_get(obj, SIMPLE_CLASS);
|
||||||
if (pd->a != 2)
|
fail_if(pd->a != 2);
|
||||||
{
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
eobj_unref(obj);
|
eobj_unref(obj);
|
||||||
|
|
||||||
obj = eobj_add(INHERIT3_CLASS, NULL);
|
obj = eobj_add(INHERIT3_CLASS, NULL);
|
||||||
|
|
||||||
eobj_do(obj, SIMPLE_A_SET(1));
|
eobj_do(obj, SIMPLE_A_SET(1));
|
||||||
pd = eobj_data_get(obj, SIMPLE_CLASS);
|
pd = eobj_data_get(obj, SIMPLE_CLASS);
|
||||||
if (pd->a != 3)
|
fail_if(pd->a != 3);
|
||||||
{
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
eobj_unref(obj);
|
eobj_unref(obj);
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,10 @@
|
||||||
#include "Eobj.h"
|
#include "Eobj.h"
|
||||||
#include "simple.h"
|
#include "simple.h"
|
||||||
|
|
||||||
|
#include "../eunit_tests.h"
|
||||||
|
|
||||||
|
static int cb_count = 0;
|
||||||
|
|
||||||
static Eina_Bool
|
static Eina_Bool
|
||||||
_a_changed_cb(void *data, Eobj *obj, const Eobj_Event_Description *desc, void *event_info)
|
_a_changed_cb(void *data, Eobj *obj, const Eobj_Event_Description *desc, void *event_info)
|
||||||
{
|
{
|
||||||
|
@ -10,6 +14,8 @@ _a_changed_cb(void *data, Eobj *obj, const Eobj_Event_Description *desc, void *e
|
||||||
int new_a = *((int *) event_info);
|
int new_a = *((int *) event_info);
|
||||||
printf("%s event_info:'%d' data:'%s'\n", __func__, new_a, (const char *) data);
|
printf("%s event_info:'%d' data:'%s'\n", __func__, new_a, (const char *) data);
|
||||||
|
|
||||||
|
cb_count++;
|
||||||
|
|
||||||
/* Fix data is NULL, stop. */
|
/* Fix data is NULL, stop. */
|
||||||
return !!data;
|
return !!data;
|
||||||
}
|
}
|
||||||
|
@ -33,6 +39,8 @@ main(int argc, char *argv[])
|
||||||
|
|
||||||
eobj_do(obj, SIMPLE_A_SET(1));
|
eobj_do(obj, SIMPLE_A_SET(1));
|
||||||
|
|
||||||
|
fail_if(cb_count != 3);
|
||||||
|
|
||||||
eobj_event_callback_del_full(obj, SIG_A_CHANGED, _a_changed_cb, NULL);
|
eobj_event_callback_del_full(obj, SIG_A_CHANGED, _a_changed_cb, NULL);
|
||||||
|
|
||||||
eobj_unref(obj);
|
eobj_unref(obj);
|
||||||
|
|
Loading…
Reference in New Issue