X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=src%2Futil%2Ftest_container_multihashmap.c;h=bd193324c02fce9a64ffc5c5b962e731ee3b2211;hb=17516001adc7afeea0c32a226e0cd7090813241a;hp=ff50df11790723288a4e6d3702f321338e95554d;hpb=a60b958f984d08525b636a2c7eae564ebec54ae6;p=oweals%2Fgnunet.git diff --git a/src/util/test_container_multihashmap.c b/src/util/test_container_multihashmap.c index ff50df117..bd193324c 100644 --- a/src/util/test_container_multihashmap.c +++ b/src/util/test_container_multihashmap.c @@ -1,6 +1,6 @@ /* This file is part of GNUnet. - (C) 2008 Christian Grothoff (and other contributing authors) + Copyright (C) 2008 GNUnet e.V. GNUnet is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published @@ -14,8 +14,8 @@ You should have received a copy of the GNU General Public License along with GNUnet; see the file COPYING. If not, write to the - Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. + Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. */ /** @@ -25,8 +25,7 @@ */ #include "platform.h" -#include "gnunet_common.h" -#include "gnunet_container_lib.h" +#include "gnunet_util_lib.h" #define ABORT() { fprintf(stderr, "Error at %s:%d\n", __FILE__, __LINE__); if (m != NULL) GNUNET_CONTAINER_multihashmap_destroy(m); return 1; } #define CHECK(c) { if (! (c)) ABORT(); } @@ -37,6 +36,8 @@ testMap (int i) struct GNUNET_CONTAINER_MultiHashMap *m; struct GNUNET_HashCode k1; struct GNUNET_HashCode k2; + struct GNUNET_CONTAINER_MultiHashMapIterator *iter; + struct GNUNET_HashCode key_ret; const char *ret; int j; @@ -79,11 +80,25 @@ testMap (int i) CHECK (2 == GNUNET_CONTAINER_multihashmap_get_multiple (m, &k1, NULL, NULL)); CHECK (0 == GNUNET_CONTAINER_multihashmap_get_multiple (m, &k2, NULL, NULL)); CHECK (2 == GNUNET_CONTAINER_multihashmap_iterate (m, NULL, NULL)); + iter = GNUNET_CONTAINER_multihashmap_iterator_create (m); + CHECK (GNUNET_YES == GNUNET_CONTAINER_multihashmap_iterator_next (iter, &key_ret, (const void **)&ret)); + CHECK (0 == memcmp (&key_ret, &k1, sizeof (key_ret))); + CHECK (GNUNET_YES == GNUNET_CONTAINER_multihashmap_iterator_next (iter, &key_ret, (const void **)&ret)); + CHECK (0 == memcmp (&key_ret, &k1, sizeof (key_ret))); + CHECK (GNUNET_NO == GNUNET_CONTAINER_multihashmap_iterator_next (iter, NULL, NULL)); + GNUNET_free (iter); + CHECK (2 == GNUNET_CONTAINER_multihashmap_remove_all (m, &k1)); for (j = 0; j < 1024; j++) CHECK (GNUNET_OK == GNUNET_CONTAINER_multihashmap_put (m, &k1, "v2", GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE)); + iter = GNUNET_CONTAINER_multihashmap_iterator_create (m); + for (j = 0; j < GNUNET_CONTAINER_multihashmap_size (m); j++) + CHECK (GNUNET_YES == GNUNET_CONTAINER_multihashmap_iterator_next (iter, NULL, NULL)); + CHECK (GNUNET_NO == GNUNET_CONTAINER_multihashmap_iterator_next (iter, NULL, NULL)); + GNUNET_free (iter); + GNUNET_CONTAINER_multihashmap_destroy (m); return 0; }