diff options
author | Simon McVittie <simon.mcvittie@collabora.co.uk> | 2009-03-17 14:44:10 +0000 |
---|---|---|
committer | Simon McVittie <simon.mcvittie@collabora.co.uk> | 2009-03-17 14:44:10 +0000 |
commit | 85aa079ae7e85f5e7ea4486e0d9c39440506dbef (patch) | |
tree | 16e4568be48945e03ec73a6a07d0148099abe1a3 /tests/heap.c | |
parent | 07a1c96e574ce45fd82f4919c78df11ddc16f683 (diff) | |
download | telepathy-glib-85aa079ae7e85f5e7ea4486e0d9c39440506dbef.tar.gz |
tests: remove test- prefix from all sources
As well as making tab completion work better, this means .gitignore can
be much simpler.
Diffstat (limited to 'tests/heap.c')
-rw-r--r-- | tests/heap.c | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/tests/heap.c b/tests/heap.c new file mode 100644 index 000000000..2bf6e7d9f --- /dev/null +++ b/tests/heap.c @@ -0,0 +1,39 @@ +#include <telepathy-glib/intset.h> +#include <telepathy-glib/heap.h> + +#include <stdlib.h> +#include <time.h> +#include <stdio.h> + +static gint comparator_fn (gconstpointer a, gconstpointer b) +{ + return (a < b) ? -1 : (a == b) ? 0 : 1; +} + +int +main (int argc, + char **argv) +{ + TpHeap *heap = tp_heap_new (comparator_fn, NULL); + guint prev = 0; + guint i; + + srand (time (NULL)); + + for (i=0; i<10000; i++) + { + tp_heap_add (heap, GUINT_TO_POINTER (rand ())); + } + + while (tp_heap_size (heap)) + { + guint elem = GPOINTER_TO_INT (tp_heap_peek_first (heap)); + g_assert (elem == GPOINTER_TO_UINT (tp_heap_extract_first (heap))); + g_assert (prev <= elem); + prev = elem; + } + + tp_heap_destroy (heap); + + return 0; +} |