From ef8cc767b201e4798a060282d4a6f280094bb8cc Mon Sep 17 00:00:00 2001 From: Arthur de Jong Date: Sun, 13 Dec 2009 10:27:33 +0000 Subject: change dict and set API to perform loops with a list of strings instead of loop_first() and loop_next() functions git-svn-id: http://arthurdejong.org/svn/nss-pam-ldapd/nss-pam-ldapd@1028 ef36b2f9-881f-0410-afb5-c4e39611909c --- tests/test_set.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) (limited to 'tests/test_set.c') diff --git a/tests/test_set.c b/tests/test_set.c index 7ebfe4e..2623906 100644 --- a/tests/test_set.c +++ b/tests/test_set.c @@ -2,7 +2,7 @@ test_set.c - simple test for the set module This file is part of the nss-pam-ldapd library. - Copyright (C) 2008 Arthur de Jong + Copyright (C) 2008, 2009 Arthur de Jong This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public @@ -25,6 +25,7 @@ #include #include #include +#include #include "common/set.h" #include "compat/attrs.h" @@ -33,7 +34,8 @@ int main(int UNUSED(argc),char UNUSED(*argv[])) { SET *set; - const char *val; + const char **list; + int i; /* initialize */ set=set_new(); @@ -51,16 +53,17 @@ int main(int UNUSED(argc),char UNUSED(*argv[])) assert(!set_contains(set,"key4")); /* loop over set contents */ - set_loop_first(set); - while ((val=set_loop_next(set))!=NULL) + list=set_tolist(set); + for (i=0;list[i]!=NULL;i++) { - assert( (strcasecmp(val,"key1")==0) || - (strcasecmp(val,"key2")==0) || - (strcasecmp(val,"key3")==0) ); + assert( (strcasecmp(list[i],"key1")==0) || + (strcasecmp(list[i],"key2")==0) || + (strcasecmp(list[i],"key3")==0) ); } /* free set */ set_free(set); + free(list); return 0; } -- cgit v1.2.3