From 66122bb1f2d83ab981a96f186da3abcd61c06d3d Mon Sep 17 00:00:00 2001 From: Alexander Pickering Date: Mon, 25 Nov 2019 23:04:33 -0500 Subject: Fixed tests Fixed tests to use the new apis --- t/test_1.c | 98 ++++++++++++++++++++++++-------------------------------------- t/test_3.c | 18 ++++++++---- 2 files changed, 49 insertions(+), 67 deletions(-) diff --git a/t/test_1.c b/t/test_1.c index 9412ce3..34ee9e2 100644 --- a/t/test_1.c +++ b/t/test_1.c @@ -73,10 +73,15 @@ char t_18[] = "Test var with spaces between attribute and name:Something\nA sad little pile of bits!"; char c_1_1[] = "What is a loop with no items?\nA sad little pile of bits!"; char c_1_2[] = "What is a loop with no items?\nA sad little pile of bits!"; +char c_2_3[] = "Render error: Variable \"loop1\" was not bound to a value\n"; #define log(x) printf(x) @@ -20,7 +21,7 @@ char c_1_2[] = "What is a loop with no items?\nA sad little pile of bits!"; printf("\n\n##########\n##Test %d.%d passed\n##########\n\n\n",n,n2);\ } -#define check_isnull(n,n2,a)\ +#define check_isnull(n,n2,a,t,e)\ if(a != NULL){\ fprintf(stderr, "Error in test 3.%d.%d\n",n,n2);\ printf("Result should have been NULL\n was '%s'\n", a);\ @@ -28,6 +29,11 @@ char c_1_2[] = "What is a loop with no items?\nA sad little pile of bits!"; printf(TMPL_err(t, NULL));\ return -1;\ }else{\ + if(strcmp(TMPL_err(t,NULL),e) != 0){\ + fprintf(stderr, "Error in test 3.%d.%d\n",n,n2);\ + printf("Error was: '%s'\nShould have been: '%s'\n",TMPL_err(t,NULL),e);\ + return -1;\ + }\ printf("\n\n##########\n##Test %d.%d passed\n##########\n\n\n",n,n2);\ } @@ -39,10 +45,10 @@ char c_1_2[] = "What is a loop with no items?\nA sad little pile of bits!"; } int main(){ - log("Running tests2\n"); + log("Running tests3\n"); struct TMPL_templates* t; - struct TMPL_varlist *vl,*vl1,*vl2; - struct TMPL_loop *l1,*l2; + struct TMPL_varlist *vl; + struct TMPL_loop *l1; char* ret; size_t dummy; int err; @@ -63,10 +69,10 @@ int main(){ l1 = TMPL_alloc_loop(); TMPL_add_loop_to_varlist(vl,"notaloop",l1); ret = TMPL_render(t,vl,&dummy); - check_isnull(1,2,ret); + check_isnull(1,2,ret,t,c_2_3); TMPL_free_template(t); TMPL_free_varlist(vl); - log("Test 2 complete\n"); + log("Test 3 complete\n"); return 0; } -- cgit v1.2.3-70-g09d2