diff options
| author | Alexander Pickering <alexandermpickering@gmail.com> | 2019-02-19 16:02:41 -0500 |
|---|---|---|
| committer | Alexander Pickering <alexandermpickering@gmail.com> | 2019-02-19 16:02:41 -0500 |
| commit | 98e35971a63cdd9bab5dd63a941c57d0bd8de91e (patch) | |
| tree | 0df6695325eea1fba340d6e9223e4f60d90687aa /t | |
| parent | a8ca001a8f811403bccffed03243954f5a52b27b (diff) | |
| download | libctemplates-98e35971a63cdd9bab5dd63a941c57d0bd8de91e.tar.gz libctemplates-98e35971a63cdd9bab5dd63a941c57d0bd8de91e.tar.bz2 libctemplates-98e35971a63cdd9bab5dd63a941c57d0bd8de91e.zip | |
Added break statement
Added a break statement that can break out of loops.
Diffstat (limited to 't')
| -rw-r--r-- | t/test_2.c | 47 |
1 files changed, 47 insertions, 0 deletions
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 <stdio.h> + +#include <ctemplates.h> + +char t_1[] = "This is a <TMPL_LOOP name=\"loop1\"><TMPL_LOOP name=\"loop2\">Text<TMPL_BREAK>Text2<TMPL_END><TMPL_END>!"; +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; +} |
