aboutsummaryrefslogtreecommitdiff
path: root/t/test_3.c
diff options
context:
space:
mode:
authorAlexander Pickering <alexandermpickering@gmail.com>2019-11-25 23:04:33 -0500
committerAlexander Pickering <alexandermpickering@gmail.com>2019-11-25 23:04:58 -0500
commit66122bb1f2d83ab981a96f186da3abcd61c06d3d (patch)
treef3b8ea7c3e4320517eeacc0766ec7747d36462a7 /t/test_3.c
parent246f8e18fd52417dd768c4afe68e8a429a9d83f7 (diff)
downloadlibctemplates-66122bb1f2d83ab981a96f186da3abcd61c06d3d.tar.gz
libctemplates-66122bb1f2d83ab981a96f186da3abcd61c06d3d.tar.bz2
libctemplates-66122bb1f2d83ab981a96f186da3abcd61c06d3d.zip
Fixed tests
Fixed tests to use the new apis
Diffstat (limited to 't/test_3.c')
-rw-r--r--t/test_3.c18
1 files changed, 12 insertions, 6 deletions
diff --git a/t/test_3.c b/t/test_3.c
index dc55aa6..5cb2b0c 100644
--- a/t/test_3.c
+++ b/t/test_3.c
@@ -6,6 +6,7 @@
char t_1[] = "What is a loop with no items?<TMPL_LOOP name=\"loop1\">Something<TMPL_END>\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;
}