diff options
author | Arthur de Jong <arthur@arthurdejong.org> | 2011-06-05 11:14:12 +0200 |
---|---|---|
committer | Arthur de Jong <arthur@arthurdejong.org> | 2011-06-05 11:14:12 +0200 |
commit | 8d25c3f2a4bca981e23138c1b960b4da99e1d788 (patch) | |
tree | 2e3b88ef782fbf7936cfb32dd125c4f1e49933cd /tests/test_expr.c | |
parent | ceb7626c048fd72d0c3d9c663dd7c7f2d66338d0 (diff) |
handle expressions where the expander function returns NULL (handle it as an empty string)
git-svn-id: http://arthurdejong.org/svn/nss-pam-ldapd/nss-pam-ldapd@1471 ef36b2f9-881f-0410-afb5-c4e39611909c
Diffstat (limited to 'tests/test_expr.c')
-rw-r--r-- | tests/test_expr.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/tests/test_expr.c b/tests/test_expr.c index 3ee9773..1ea4f8d 100644 --- a/tests/test_expr.c +++ b/tests/test_expr.c @@ -50,6 +50,8 @@ static const char *expanderfn(const char *name,void UNUSED(*expander_attr)) { if (strcmp(name,"empty")==0) return ""; + if (strcmp(name,"null")==0) + return NULL; else return "foobar"; } @@ -65,6 +67,8 @@ static void test_expr_parse(void) assertstreq(buffer,""); assert(expr_parse("$foo1$empty-$foo2",buffer,sizeof(buffer),expanderfn,NULL)!=NULL); assertstreq(buffer,"foobar-foobar"); + assert(expr_parse("$foo1+$null+$foo2",buffer,sizeof(buffer),expanderfn,NULL)!=NULL); + assertstreq(buffer,"foobar++foobar"); assert(expr_parse("${test1}\\$",buffer,sizeof(buffer),expanderfn,NULL)!=NULL); assertstreq(buffer,"foobar$"); assert(expr_parse("${test1:-default}",buffer,sizeof(buffer),expanderfn,NULL)!=NULL); |