Arthur de Jong

Open Source / Free Software developer

summaryrefslogtreecommitdiffstats
path: root/tests/test_set.c
diff options
context:
space:
mode:
authorArthur de Jong <arthur@arthurdejong.org>2009-12-13 11:27:33 +0100
committerArthur de Jong <arthur@arthurdejong.org>2009-12-13 11:27:33 +0100
commitef8cc767b201e4798a060282d4a6f280094bb8cc (patch)
tree4f19eae6870321f280959be4b7b24cd0e38d4c2a /tests/test_set.c
parent7dd703c9af5f8b4a50f056c47588a9e51d4ea681 (diff)
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
Diffstat (limited to 'tests/test_set.c')
-rw-r--r--tests/test_set.c17
1 files changed, 10 insertions, 7 deletions
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 <stdio.h>
#include <string.h>
#include <assert.h>
+#include <stdlib.h>
#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;
}