diff options
author | John Mark Bell <jmb@netsurf-browser.org> | 2007-06-23 22:40:25 +0000 |
---|---|---|
committer | John Mark Bell <jmb@netsurf-browser.org> | 2007-06-23 22:40:25 +0000 |
commit | 7b30a5520cfb56e651f0eb4da85a3e07747da7dc (patch) | |
tree | 5d6281c071c089e1e7a8ae6f8044cecaf6a7db16 /test/dict.c | |
download | libhubbub-7b30a5520cfb56e651f0eb4da85a3e07747da7dc.tar.gz libhubbub-7b30a5520cfb56e651f0eb4da85a3e07747da7dc.tar.bz2 |
Import hubbub -- an HTML parsing library.
Plenty of work still to do (like tree generation ;)
svn path=/trunk/hubbub/; revision=3359
Diffstat (limited to 'test/dict.c')
-rw-r--r-- | test/dict.c | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/test/dict.c b/test/dict.c new file mode 100644 index 0000000..0c2e93e --- /dev/null +++ b/test/dict.c @@ -0,0 +1,53 @@ +#include "utils/dict.h" + +#include "testutils.h" + +static void *myrealloc(void *ptr, size_t len, void *pw) +{ + UNUSED(pw); + + return realloc(ptr, len); +} + +int main(int argc, char **argv) +{ + hubbub_dict *dict; + const void *result; + void *context = NULL; + + UNUSED(argc); + UNUSED(argv); + + dict = hubbub_dict_create(myrealloc, NULL); + assert(dict != NULL); + + assert(hubbub_dict_insert(dict, "Hello", (const void *) 123) == + HUBBUB_OK); + assert(hubbub_dict_insert(dict, "Hello1", (const void *) 456) == + HUBBUB_OK); + + assert(hubbub_dict_search_step(dict, 'H', &result, &context) == + HUBBUB_NEEDDATA); + assert(hubbub_dict_search_step(dict, 'e', &result, &context) == + HUBBUB_NEEDDATA); + assert(hubbub_dict_search_step(dict, 'l', &result, &context) == + HUBBUB_NEEDDATA); + assert(hubbub_dict_search_step(dict, 'l', &result, &context) == + HUBBUB_NEEDDATA); + assert(hubbub_dict_search_step(dict, 'o', &result, &context) == + HUBBUB_OK); + assert(result == (const void *) 123); + assert(hubbub_dict_search_step(dict, '1', &result, &context) == + HUBBUB_OK); + assert(result == (const void *) 456); + assert(hubbub_dict_search_step(dict, '\0', &result, &context) == + HUBBUB_OK); + assert(hubbub_dict_search_step(dict, 'x', &result, &context) == + HUBBUB_INVALID); + + hubbub_dict_destroy(dict); + + printf("PASS\n"); + + return 0; +} |