From 98e35971a63cdd9bab5dd63a941c57d0bd8de91e Mon Sep 17 00:00:00 2001 From: Alexander Pickering Date: Tue, 19 Feb 2019 16:02:41 -0500 Subject: Added break statement Added a break statement that can break out of loops. --- t/test_2.c | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 t/test_2.c (limited to 't') diff --git a/t/test_2.c b/t/test_2.c new file mode 100644 index 0000000..b67cca2 --- /dev/null +++ b/t/test_2.c @@ -0,0 +1,47 @@ + +#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; +} -- cgit v1.2.3-70-g09d2