diff options
author | Jérémy Zurcher <jeremy@asynk.ch> | 2012-05-31 16:39:14 +0200 |
---|---|---|
committer | Jérémy Zurcher <jeremy@asynk.ch> | 2012-05-31 16:39:14 +0200 |
commit | 4bc1b68caf1165222b7ea4080144547d388d17eb (patch) | |
tree | f54132649202d1acfb11730d0dce9d648f5b1efa /tests/main.c | |
parent | e6a53fa2a651ec15b5a2b7c5ed70af421660ca7a (diff) | |
download | edoors-4bc1b68caf1165222b7ea4080144547d388d17eb.zip edoors-4bc1b68caf1165222b7ea4080144547d388d17eb.tar.gz |
split and complete tests
Diffstat (limited to 'tests/main.c')
-rw-r--r-- | tests/main.c | 115 |
1 files changed, 6 insertions, 109 deletions
diff --git a/tests/main.c b/tests/main.c index 6de02a1..b19b5f4 100644 --- a/tests/main.c +++ b/tests/main.c @@ -1,120 +1,17 @@ -#include "Eiotas.h" -#include <eina_log.h> -#include <stdio.h> - -#undef PRINTPTR -#ifdef __clang__ -# define PRINTPTR(_p) (unsigned int)_p -#else -# define PRINTPTR(_p) (_p) -#endif - -typedef struct { - char txt[32]; - int idx; -} Input; - -static Input* input_create(char *txt) -{ - Input *input = (Input*)malloc(sizeof(Input)); - strncpy(input->txt,txt,32); - input->txt[31] = '\0'; - input->idx = 0; - return input; -} - -static void input_free(Input *input) -{ - EINA_LOG_DOM_DBG(_eiotas_log_dom,"free Input\n"); - free(input); -} - -static void input_show(Input *input) -{ - EINA_LOG_DOM_DBG(_eiotas_log_dom,"Input [%d] %s\n",input->idx,input->txt); -} - -static void input_receive(const Eiotas_Door *door, Eiotas_Particle *particle, Eiotas_User_Data *data) -{ - EINA_LOG_DOM_DBG(_eiotas_log_dom,"input_receive 0x%X\n",PRINTPTR(data)); -} +#include "helper.h" int main(int argc, char **argv) { - int i; - Eiotas_Particle *p0, *p1, *p2, *p3, *p4, *p5, *p6, *p7, *p8, *p9, *p10; - if(eiotas_init()==0) { return EXIT_FAILURE; } - eina_log_domain_level_set("eiotas",EINA_LOG_LEVEL_DBG); - EINA_LOG_DOM_DBG(_eiotas_log_dom,"Eiotas version %d.%d.%d",eiotas_version->major,eiotas_version->minor,eiotas_version->micro); + eina_log_domain_level_set("eiotas",EINA_LOG_LEVEL_ERR); + EINA_LOG_DOM_INFO(_eiotas_log_dom,"Eiotas version %d.%d.%d",eiotas_version->major,eiotas_version->minor,eiotas_version->micro); - Eiotas_Spin *dom0 = eiotas_spin_add("dom0",10); - eiotas_iota_show((Eiotas_Iota*)dom0); - - Eiotas_Room *room = &dom0->room; - char name[8]; - for(i=0; i<5; i++) { - sprintf(name,"room%d",i); - Eiotas_Room *tmp = eiotas_room_add(name,room); - if(tmp!=NULL) { - room = tmp; - eiotas_iota_show((Eiotas_Iota*)room); // MACROS - } - } - room = eiotas_room_add("room0",&dom0->room); - - Input *input = input_create("hello world"); - input_show(input); - - Eiotas_User_Bits user_bits; - - user_bits.data = input; - user_bits.free_fct = (Eiotas_User_Data_Free)&input_free; - user_bits.recv_fct = (Eiotas_Receive_Particle)&input_receive; - Eiotas_Door *din0 = eiotas_door_add("input0",&dom0->room,&user_bits); - eiotas_iota_show(&din0->iota); // eiotas_iota_show((Eiotas_Iota*)din0); - - p0 = eiotas_require_particle(din0); - p1 = eiotas_require_particle(din0); - p2 = eiotas_require_particle(din0); - p3 = eiotas_require_particle(din0); - p4 = eiotas_require_particle(din0); - p5 = eiotas_require_particle(din0); - p6 = eiotas_require_particle(din0); - p7 = eiotas_require_particle(din0); - p8 = eiotas_require_particle(din0); - p9 = eiotas_require_particle(din0); - - eiotas_release_particle(din0,p0); - eiotas_release_particle(din0,p1); - p10 = eiotas_require_particle(din0); - if(p10!=p1) { - fprintf(stderr,"Particle require fail\n"); - } - eiotas_release_particle(din0,p10); - - eiotas_spin_send_particle((Eiotas_Spin*)din0->iota.spin,p2,EINA_FALSE); - eiotas_spin_send_particle((Eiotas_Spin*)din0->iota.spin,p3,EINA_TRUE); - - eiotas_particle_merge(p4,p5); - eiotas_particle_merge(p4,p6); - eiotas_particle_merge(p5,p7); - eiotas_particle_merge(p5,p8); - eiotas_particle_merge(p5,p9); - - eiotas_particle_add_destinations(p4,"dom0/room0/door0?get"); - eiotas_particle_add_destinations(p4," dom0/room0/door0?get "); - eiotas_particle_add_destinations(p4," dom0/room0/door0?get "); - eiotas_particle_add_destinations(p4,"dom0/room0/room1/doorx?get,door?get,dom0/room0/door0?get"); - eiotas_particle_add_destinations(p4," dom0/room0/room1/doorx?get,door?get , dom0/room0/door0?get "); - eiotas_particle_add_destinations(p4," , , dom0/room0/room1/doorx?get,door?get ,, dom0/room0/door0?get "); - - eiotas_release_particle(din0,p4); - - eiotas_spin_free(dom0); + test_spin(); + test_particle(); return eiotas_shutdown(); } + |