summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorEmmanuele Bassi <ebassi@gnome.org>2007-04-11 13:09:38 +0000
committerEmmanuele Bassi <ebassi@src.gnome.org>2007-04-11 13:09:38 +0000
commitdb8642a56c0436aeb730ead593140bc01b82d4ac (patch)
tree0c7adfb54d0ec9af16aee6de6dcc3be660740342 /tests
parente542f521efb15d9ed4aa776cccfab9a55c9e7922 (diff)
Add g_hash_table_get_keys() and g_hash_table_get_values(), API to retrieve
2007-04-11 Emmanuele Bassi <ebassi@gnome.org> * glib/ghash.[ch]: Add g_hash_table_get_keys() and g_hash_table_get_values(), API to retrieve the keys and values inside an hash table in list form. (#413133) * glib/glib.symbols: Update symbols. * tests/hash-test.c: Exercise newly added functions. svn path=/trunk/; revision=5444
Diffstat (limited to 'tests')
-rw-r--r--tests/hash-test.c20
1 files changed, 19 insertions, 1 deletions
diff --git a/tests/hash-test.c b/tests/hash-test.c
index 00074fb1b..da77dd38b 100644
--- a/tests/hash-test.c
+++ b/tests/hash-test.c
@@ -342,7 +342,9 @@ main (int argc,
GHashTable *hash_table;
gint i;
gint value = 120;
- gint *pvalue;
+ gint *pvalue;
+ GList *keys, *values;
+ gint keys_len, values_len;
hash_table = g_hash_table_new (my_hash, my_hash_equal);
for (i = 0; i < 10000; i++)
@@ -353,6 +355,22 @@ main (int argc,
pvalue = g_hash_table_find (hash_table, find_first, &value);
if (!pvalue || *pvalue != value)
g_assert_not_reached();
+
+ keys = g_hash_table_get_keys (hash_table);
+ if (!keys)
+ g_assert_not_reached ();
+
+ values = g_hash_table_get_values (hash_table);
+ if (!values)
+ g_assert_not_reached ();
+
+ keys_len = g_list_length (keys);
+ values_len = g_list_length (values);
+ if (values_len != keys_len && keys_len != g_hash_table_size (hash_table))
+ g_assert_not_reached ();
+
+ g_list_free (keys);
+ g_list_free (values);
g_hash_table_foreach (hash_table, my_hash_callback, NULL);