diff options
author | John Mark Bell <jmb@netsurf-browser.org> | 2007-09-22 13:32:42 +0000 |
---|---|---|
committer | John Mark Bell <jmb@netsurf-browser.org> | 2007-09-22 13:32:42 +0000 |
commit | f1f80696ebe87520de0c857371e0ca109fce68cb (patch) | |
tree | 66b241e6ef7384e9bed2b57b11c5d8f075601b12 /test/lib/list.h | |
parent | dac9bafa302a42ef8e58fa017739cc29a046413f (diff) | |
download | libdom-f1f80696ebe87520de0c857371e0ca109fce68cb.tar.gz libdom-f1f80696ebe87520de0c857371e0ca109fce68cb.tar.bz2 |
Create a library of utility functions for the testsuite to use
Make test/binding.c include stdio.h itself rather than relying on other things to include it.
svn path=/trunk/dom/; revision=3568
Diffstat (limited to 'test/lib/list.h')
-rw-r--r-- | test/lib/list.h | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/test/lib/list.h b/test/lib/list.h new file mode 100644 index 0000000..a0a6c6a --- /dev/null +++ b/test/lib/list.h @@ -0,0 +1,44 @@ +/* + * This file is part of libdom test suite. + * Licensed under the MIT License, + * http://www.opensource.org/licenses/mit-license.php + * Copyright 2007 James Shaw <jshaw@netsurf-browser.org> + */ + +#ifndef list_h_ +#define list_h_ + +struct list_elt { + void* data; + struct list_elt* next; +}; + +struct list { + unsigned int size; + struct list_elt* head; + struct list_elt* tail; +}; + +struct list* list_new(void); +void list_destroy(struct list* list); + +typedef int (*list_compare_func)(const void* a, const void* b); + +/** + * Add data to the tail of the list. + */ +void list_add(struct list* list, void* data); + +/** + * Tests if data is equal to any element in the list. + */ +bool list_contains(struct list* list, void* data, + int (*comparator)(const void* a, const void* b)); + +/** + * Tests if superlist contains all elements in sublist. Order is not important. + */ +bool list_contains_all(struct list* superList, struct list* subList, + list_compare_func comparator); + +#endif |