summaryrefslogtreecommitdiff
path: root/tests
AgeCommit message (Collapse)AuthorFilesLines
2016-03-02Add a testcase for the replacement bug fixed in the previous commit.Eric Anholt9-0/+197
2016-03-02Fix replacement of deleted entries in the int set.Eric Anholt3-0/+61
Caught while writing tests for the next bugfix.
2016-03-02Add a testcase for a bug that was introduced in Mesa.Eric Anholt6-0/+132
This tree doesn't have the bug, but I'd like to bring the change that was buggy over.
2016-03-02Fix compiler warning in delete_management.Eric Anholt1-1/+0
2014-11-25Make helpers for creating hash tables and sets of strings.Eric Anholt9-9/+9
This fixes warnings when building the testsuite, due to char * vs void * in prototypes.
2013-10-25Teach the hash table itself to know its own hash functionCarl Worth17-105/+107
Here, we change 'create' to accept the hash function. This simplifies the interface for 'insert', 'search', 'contains', and 'remove' which no longer need to pass a hash value, making them more convenient to use. To avoid any reduction in performance, the previous interfaces for 'insert' and 'search' are still available as 'insert_pre_hashed' and 'search_pre_hashed'. This avoids redundant hashing in cases where the caller already has a hash value. (The common case is to has once before 'search_pre_hashed' and then reuse that value for 'insert_pre_hashed'.) The implementation takes advantage of the 'insert_pre_hashed' version when performing hash_rehash as part of resizing the table. Note that 'remove' does not need a pre_hashed variant since 'remove' is already a convenience function on top of 'remove_entry', and 'remove_entry' already has access to the hash value inside of the entry. Similarly, 'contains' does not need a pre_hashed variant since it is a convnience function on top of 'search' which already has a 'search_pre_hashed' variant. In this commit, the tests are modified such that roughly half of the previous callers of 'search' and 'insert' are changed to the new interface and the other half remain with the old interface (now named 'search_pre_hashed' and 'insert_pre_hashed'). v2: Make the new method call style consistent with the key equality method (change by anholt).
2013-10-25Fix out-of-tree build.Eric Anholt3-3/+3
2013-10-25Add set_contains and int_set_contains functions.Carl Worth10-0/+24
These are convenience functions on top of set_search and int_set_search. With a set, containment is often the most important notion of interest, and it helps to be able to query this without needing to declare a local struct set_entry*. v2: Whitespace consistency (changes by anholt)
2013-10-25Add new convenience function 'remove' (renaming former to 'remove_entry')Carl Worth13-24/+48
The new 'remove' function provides a parallel interface to that of search, (removing an entry matching the provided data). The former remove function (which accepts a pointer to a known entry) is renamed to 'remove_entry'. This new 'remove' is a simple convenience function which calls 'search' and then 'remove_entry'. As can be seen in the updates to the test suite, there are cases where the caller was already doing exactly that, so the new interface simplifies such uses. v2: Whitespace consistency change (by anholt)
2013-10-25Add a new int-set structure for a set of integersCarl Worth11-1/+521
Much like the motivation for the original set.c, this int-set.c code is not difficult, but it makes sense to do this up-front in the original hash_table module (with testing) rather than expecting users to repeat this work.
2013-10-25Standardize language for license blurbs.Carl Worth2-14/+16
This extends the language from the source files into the Makefiles as well. The most significant change is from "ADAM JACKSON" to "THE AUTHORS OR COPYRIGHT HOLDERS". While I'm sure that Adam would appreciate any reduction in liability, the intent of this language is to disclaim liability for the actual authors and copyright holders. (I don't know that Adam actually has any copyright interest in this implementation, but if he does, he's still covered by the wider language.)
2013-10-25Update .gitignore filesCarl Worth2-0/+5
Just enough to keep "git status" clean after running "make check".
2012-11-06Add a test case for handling of collisions.Eric Anholt2-0/+82
2011-08-18Add a set implementation derived from the hash_table implementation.Eric Anholt12-0/+643
While it was easy to produce, it's easier to do it once and maintain it than leave this up to every possible user. Plus, it means it gets testing.
2011-08-18Make hash_table_remove(ht, NULL) do nothing instead of segfault.Eric Anholt3-0/+48
2011-08-18Add defined behavior for inserts with matching keys, and a test.Eric Anholt3-0/+65
2009-11-24Prevent ht->entries from doubling when rehashing.Eric Anholt2-0/+2
2009-11-23Fix valgrind complaints, including leaking the table data!Eric Anholt5-5/+5
2009-11-23Add a testcase for the upcoming deletion management code.Eric Anholt5-3/+99
2009-11-23API change: pass the hash value in to search/lookup.Eric Anholt5-43/+29
This avoids re-hashing the key for the common use case of searching for the key's presence, then creating the entry if it isn't.
2009-11-23Add an interface for choosing a random hash table entry with a predicate.Eric Anholt3-0/+102
2009-11-23destroy_callback: New test for the destroy hashtable callback.Eric Anholt2-0/+66
2009-11-23New test for expanding the hash table and not losing entries.Eric Anholt3-0/+81
2009-11-23Add a new test for removal of keys from the ht, and fix up API naming.Eric Anholt2-0/+74
2009-11-23Add testing infrastructure.Eric Anholt3-0/+123