Arthur de Jong

Open Source / Free Software developer

summaryrefslogtreecommitdiffstats
path: root/tests/test_dict.c
diff options
context:
space:
mode:
authorArthur de Jong <arthur@arthurdejong.org>2008-04-17 23:12:21 +0200
committerArthur de Jong <arthur@arthurdejong.org>2008-04-17 23:12:21 +0200
commit2e48b85903b04117f9314b9ed69f0ac2d4d78356 (patch)
tree3414b0f55788c52c3ed8da25977ddb632a3f0c4e /tests/test_dict.c
parent15b3f8bc5a757d984e5510fdaec46196d8939a56 (diff)
change dict_values_first() and dict_values_next() into dict_loop_first() and dict_loop_next() to have a looping mechanism over keys and values
git-svn-id: http://arthurdejong.org/svn/nss-pam-ldapd/nss-ldapd@675 ef36b2f9-881f-0410-afb5-c4e39611909c
Diffstat (limited to 'tests/test_dict.c')
-rw-r--r--tests/test_dict.c33
1 files changed, 16 insertions, 17 deletions
diff --git a/tests/test_dict.c b/tests/test_dict.c
index 7cfc169..4c19c2b 100644
--- a/tests/test_dict.c
+++ b/tests/test_dict.c
@@ -2,7 +2,7 @@
test_dict.c - simple test for the dict module
This file is part of the nss-ldapd library.
- Copyright (C) 2007 Arthur de Jong
+ Copyright (C) 2007, 2008 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
@@ -33,7 +33,8 @@
int main(int UNUSED(argc),char UNUSED(*argv[]))
{
DICT *dict;
- void *ret;
+ const char *key;
+ void *val;
static char *value1="value1";
static char *value2="value2";
static char *replace2="replace2";
@@ -48,31 +49,29 @@ int main(int UNUSED(argc),char UNUSED(*argv[]))
dict_put(dict,"KEY2",replace2);
/* check dictionary contents */
- ret=dict_get(dict,"KeY1");
- assert(ret==value1);
- ret=dict_get(dict,"kEy2");
- assert(ret==replace2);
- ret=dict_get(dict,"KeY3");
- assert(ret==dict);
- ret=dict_get(dict,"key4");
- assert(ret==NULL);
+ val=dict_get(dict,"KeY1");
+ assert(val==value1);
+ val=dict_get(dict,"kEy2");
+ assert(val==replace2);
+ val=dict_get(dict,"KeY3");
+ assert(val==dict);
+ val=dict_get(dict,"key4");
+ assert(val==NULL);
/* remove a key */
dict_put(dict,"kEy3",NULL);
- ret=dict_get(dict,"keY3");
- assert(ret==NULL);
+ val=dict_get(dict,"keY3");
+ assert(val==NULL);
/* loop over dictionary contents */
- dict_values_first(dict);
- while ((ret=dict_values_next(dict))!=NULL)
+ dict_loop_first(dict);
+ while (dict_loop_next(dict,&key,&val)!=NULL)
{
- assert(((ret==value1)||(ret==replace2)));
+ assert(((val==value1)||(val==replace2)));
}
/* free dictionary */
dict_free(dict);
- /* TODO: test dict_values_first() and dict_values_next() */
-
return 0;
}