Mercurial > gnulib
diff tests/test-hash.c @ 11637:0b026e877c96
hash: provide default callback functions
* lib/hash.c (raw_hasher, raw_comparator): New functions.
(hash_initialize): Use them as defaults.
* tests/test-hash.c (main): Test this.
Signed-off-by: Eric Blake <ebb9@byu.net>
author | Eric Blake <ebb9@byu.net> |
---|---|
date | Thu, 18 Jun 2009 07:11:39 -0600 |
parents | 95fd221d763c |
children | 560a14733476 |
line wrap: on
line diff
--- a/tests/test-hash.c Thu Jun 18 06:56:13 2009 -0600 +++ b/tests/test-hash.c Thu Jun 18 07:11:39 2009 -0600 @@ -135,6 +135,18 @@ hash_clear (ht); ASSERT (hash_get_n_entries (ht) == 0); hash_free (ht); + + /* Test pointer hashing. */ + ht = hash_initialize (sz, NULL, NULL, NULL, NULL); + ASSERT (ht); + { + char *str = xstrdup ("a"); + insert_new (ht, "a"); + insert_new (ht, str); + ASSERT (hash_lookup (ht, str) == str); + free (str); + } + hash_free (ht); } /* Now, each entry is malloc'd. */