diff options
author | Arthur de Jong <arthur@arthurdejong.org> | 2010-10-15 12:31:11 +0200 |
---|---|---|
committer | Arthur de Jong <arthur@arthurdejong.org> | 2010-10-15 12:31:11 +0200 |
commit | f6bbbc5da9d72ec6637ef8fea58c73686abdace1 (patch) | |
tree | 523ca9a9ab64a3d5bd3623b51ad2bf50a556faf3 /tests/test_set.c | |
parent | e6100f8a81d178f1307571a5773931dd976986c2 (diff) |
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
Diffstat (limited to 'tests/test_set.c')
-rw-r--r-- | tests/test_set.c | 18 |
1 files changed, 15 insertions, 3 deletions
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); |