From f6bbbc5da9d72ec6637ef8fea58c73686abdace1 Mon Sep 17 00:00:00 2001 From: Arthur de Jong Date: Fri, 15 Oct 2010 10:31:11 +0000 Subject: implement dict_getany() and set_pop() functions to be able to pick and remove entries git-svn-id: http://arthurdejong.org/svn/nss-pam-ldapd/nss-pam-ldapd@1279 ef36b2f9-881f-0410-afb5-c4e39611909c --- tests/test_set.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) (limited to 'tests/test_set.c') diff --git a/tests/test_set.c b/tests/test_set.c index 7adaf21..6f72b4d 100644 --- a/tests/test_set.c +++ b/tests/test_set.c @@ -30,6 +30,14 @@ #include "common/set.h" #include "compat/attrs.h" +static int isknownvalue(const char *value) +{ + return value!=NULL && ( + (strcmp(value,"key1")==0) || + (strcmp(value,"key2")==0) || + (strcmp(value,"key3")==0) ); +} + /* the main program... */ int main(int UNUSED(argc),char UNUSED(*argv[])) { @@ -57,11 +65,15 @@ int main(int UNUSED(argc),char UNUSED(*argv[])) list=set_tolist(set); for (i=0;list[i]!=NULL;i++) { - assert( (strcmp(list[i],"key1")==0) || - (strcmp(list[i],"key2")==0) || - (strcmp(list[i],"key3")==0) ); + assert(isknownvalue(list[i])); } + /* remove keys from the set */ + assert(isknownvalue(set_pop(set))); + assert(isknownvalue(set_pop(set))); + assert(isknownvalue(set_pop(set))); + assert(set_pop(set)==NULL); + /* free set */ set_free(set); free(list); -- cgit v1.2.3