diff options
| author | Alexander Pickering <alexandermpickering@gmail.com> | 2018-10-13 19:38:48 -0400 |
|---|---|---|
| committer | Alexander Pickering <alexandermpickering@gmail.com> | 2018-10-13 19:38:48 -0400 |
| commit | 5c12d59ad16ab903e3956aeb0340e52eb3e67af8 (patch) | |
| tree | d8df1317f09dbda12981183a7755960f2c29d203 /t | |
| parent | b6440b2be8ee8069ed050ba61ee9767f9fb04c2f (diff) | |
| download | libctemplates-5c12d59ad16ab903e3956aeb0340e52eb3e67af8.tar.gz libctemplates-5c12d59ad16ab903e3956aeb0340e52eb3e67af8.tar.bz2 libctemplates-5c12d59ad16ab903e3956aeb0340e52eb3e67af8.zip | |
Added another test
Added another test case to the test file.
Diffstat (limited to 't')
| -rw-r--r-- | t/test_1.c | 56 |
1 files changed, 53 insertions, 3 deletions
@@ -63,6 +63,16 @@ char c_14_1[] = "Test if with empty value: Correct!"; char t_15[] = "Test elseif with empty value:<TMPL_IF name=\"missing\"> Wrong<TMPL_ELSEIF name=\"var\" value=\"\"> Correct!<TMPL_END>"; char c_15_1[] = "Test elseif with empty value: Correct!"; +char t_16[] = "Test var with spaces:<TMPL_VAR name=\"test\">"; +char c_16_1[] = "Test var with spaces:Test"; + +char t_17[] = "Test var with spaces and default:<TMPL_VAR name=\"test\" default=\"Correct!\">"; +char c_17_1[] = "Test var with spaces and default:Correct!"; + +char t_18[] = "Test var with spaces between attribute and name:<TMPL_VAR name =\"test\" default = \"Correct!\">"; +char c_18_1[] = "Test var with spaces between attribute and name:Correct!"; +char c_18_2[] = "Test var with spaces between attribute and name:Blah"; + int main(){ struct TMPL_templates* t; struct TMPL_varlist* vl; @@ -169,7 +179,7 @@ int main(){ ret = TMPL_render(t,vl,&dummy); if(strcmp(ret,c_7_2) != 0){ fprintf(stderr, "Error in test file 1, test 7\n"); - printf("Result should have been '%s'\n was '%s'\n",c_7_1,ret); + printf("Result should have been '%s'\n was '%s'\n",c_7_2,ret); return -1; } TMPL_free_varlist(vl); @@ -190,7 +200,7 @@ int main(){ ret = TMPL_render(t,vl,&dummy); if(strcmp(ret,c_7_3) != 0){ fprintf(stderr, "Error in test file 1, test 7\n"); - printf("Result should have been '%s'\n was '%s'\n",c_7_1,ret); + printf("Result should have been '%s'\n was '%s'\n",c_7_3,ret); return -1; } TMPL_free_varlist(vl); @@ -375,7 +385,47 @@ int main(){ TMPL_free_varlist(vl); TMPL_free_template(t); + /*Test 16: var with multiple spaces in between*/ + t = TMPL_alloc_template(t_16); + vl = TMPL_alloc_varlist(); + TMPL_add_var_to_varlist(vl,"test","Test"); + ret = TMPL_render(t,vl,&dummy); + if(strcmp(ret,c_16_1) != 0){ + fprintf(stderr, "Error in test file 1, test 16\n"); + printf("Result should have been '%s\n was '%s'\n",c_16_1,ret); + return -1; + } + TMPL_free_varlist(vl); + TMPL_free_template(t); - + /*Test 17: var with multiple spaces in between, and a default*/ + t = TMPL_alloc_template(t_17); + vl = TMPL_alloc_varlist(); + ret = TMPL_render(t,vl,&dummy); + if(strcmp(ret,c_17_1) != 0){ + fprintf(stderr, "Error in test file 1, test 17\n"); + printf("Result should have been '%s\n was '%s'\n",c_17_1,ret); + return -1; + } + TMPL_free_varlist(vl); + TMPL_free_template(t); + + /*printf("Before test 18\n");*/ + /*Test 18: spaces between attribute and value*/ + t = TMPL_alloc_template(t_18); + /*print_ast(t->roottag);*/ + /*printf("Alloced template\n");*/ + vl = TMPL_alloc_varlist(); + /*printf("Made varles\n");*/ + ret = TMPL_render(t,vl,&dummy); + /*printf("Rendered\n");*/ + if(strcmp(ret,c_18_1) != 0){ + fprintf(stderr, "Error in test file 1, test 18\n"); + printf("Result should have been '%s\n was '%s'\n",c_18_1,ret); + return -1; + } + TMPL_free_varlist(vl); + TMPL_free_template(t); + return 0; } |
