#include #include char t_1[] = "This is a TextText2!"; char c_1_1[] = "This is a Text!"; #define log(x) printf(x) int main(){ log("Running tests2\n"); struct TMPL_templates* t; struct TMPL_varlist *vl,*vl1,*vl2; struct TMPL_loop *l1,*l2; char* ret; size_t dummy; /*Test 1: Variable*/ t = TMPL_alloc_template(t_1); vl = TMPL_alloc_varlist(); TMPL_add_var_to_varlist(vl,"what","template"); l1 = TMPL_alloc_loop(); vl1 = TMPL_alloc_varlist(); l2 = TMPL_alloc_loop(); vl2 = TMPL_alloc_varlist(); TMPL_add_varlist_to_loop(l2,vl2); TMPL_add_loop_to_varlist(vl1,"loop2",l2); TMPL_add_varlist_to_loop(l1,vl1); TMPL_add_loop_to_varlist(vl,"loop1",l1); ret = TMPL_render(t,vl,&dummy); if(strcmp(ret,c_1_1) != 0){ fprintf(stderr,"Error in test file 2, test 1\n"); printf("Result should have been '%s'\n was '%s'\n",c_1_1,ret); if(t->error) printf(TMPL_err(t, NULL)); return -1; } TMPL_free_template(t); TMPL_free_varlist(vl); log("Test 1 complete\n"); return 0; }