1 #undef G_DISABLE_ASSERT
11 check_integrity (GQueue *queue)
19 g_assert (queue->length < 4000000000u);
21 g_assert (g_queue_get_length (queue) == queue->length);
24 g_assert (!queue->tail);
26 g_assert (!queue->head);
30 for (list = queue->head; list != NULL; list = list->next)
36 g_assert (n == queue->length);
37 g_assert (last == queue->tail);
41 for (list = queue->tail; list != NULL; list = list->prev)
47 g_assert (n == queue->length);
48 g_assert (last == queue->head);
51 for (list = queue->head; list != NULL; list = list->next)
52 links = g_list_prepend (links, list);
55 for (list = queue->tail; list != NULL; list = list->prev)
57 g_assert (list == link->data);
63 for (list = queue->tail; list != NULL; list = list->prev)
64 links = g_list_prepend (links, list);
67 for (list = queue->head; list != NULL; list = list->next)
69 g_assert (list == link->data);
78 return g_random_int_range (0, 2);
82 check_max (gpointer elm, gpointer user_data)
84 gint *best = user_data;
85 gint element = GPOINTER_TO_INT (elm);
92 check_min (gpointer elm, gpointer user_data)
94 gint *best = user_data;
95 gint element = GPOINTER_TO_INT (elm);
102 find_min (GQueue *queue)
106 g_queue_foreach (queue, check_min, &min);
112 find_max (GQueue *queue)
116 g_queue_foreach (queue, check_max, &max);
122 delete_elm (gpointer elm, gpointer user_data)
124 g_queue_remove ((GQueue *)user_data, elm);
125 check_integrity ((GQueue *)user_data);
129 delete_all (GQueue *queue)
131 g_queue_foreach (queue, delete_elm, queue);
135 compare_int (gconstpointer a, gconstpointer b, gpointer data)
137 int ai = GPOINTER_TO_INT (a);
138 int bi = GPOINTER_TO_INT (b);
149 get_random_position (GQueue *queue, gboolean allow_offlist)
152 enum { OFF_QUEUE, HEAD, TAIL, MIDDLE, LAST } where;
155 where = g_random_int_range (OFF_QUEUE, LAST);
157 where = g_random_int_range (HEAD, LAST);
173 n = queue->length - 1;
177 if (queue->length == 0)
180 n = g_random_int_range (0, queue->length);
184 g_assert_not_reached();
194 random_test (gconstpointer d)
196 guint32 seed = GPOINTER_TO_UINT (d);
199 IS_EMPTY, GET_LENGTH, REVERSE, COPY,
200 FOREACH, FIND, FIND_CUSTOM, SORT,
201 PUSH_HEAD, PUSH_TAIL, PUSH_NTH, POP_HEAD,
202 POP_TAIL, POP_NTH, PEEK_HEAD, PEEK_TAIL,
203 PEEK_NTH, INDEX, REMOVE, REMOVE_ALL,
204 INSERT_BEFORE, INSERT_AFTER, INSERT_SORTED, PUSH_HEAD_LINK,
205 PUSH_TAIL_LINK, PUSH_NTH_LINK, POP_HEAD_LINK, POP_TAIL_LINK,
206 POP_NTH_LINK, PEEK_HEAD_LINK, PEEK_TAIL_LINK, PEEK_NTH_LINK,
207 LINK_INDEX, UNLINK, DELETE_LINK, LAST_OP
210 #define N_ITERATIONS 500000
213 #define RANDOM_QUEUE() &(queues[g_random_int_range(0, N_QUEUES)])
215 typedef struct QueueInfo QueueInfo;
226 QueueInfo queues[N_QUEUES];
228 g_random_set_seed (seed);
230 for (i = 0; i < N_QUEUES; ++i)
232 queues[i].queue = g_queue_new ();
233 queues[i].head = NULL;
234 queues[i].tail = NULL;
235 queues[i].length = 0;
238 for (i = 0; i < N_ITERATIONS; ++i)
241 QueueInfo *qinf = RANDOM_QUEUE();
242 GQueue *q = qinf->queue;
243 op = g_random_int_range (IS_EMPTY, LAST_OP);
245 g_assert (qinf->head == q->head);
246 g_assert (qinf->tail == q->tail);
247 g_assert (qinf->length == q->length);
253 if (g_queue_is_empty (qinf->queue))
255 g_assert (q->head == NULL);
256 g_assert (q->tail == NULL);
257 g_assert (q->length == 0);
263 g_assert (q->length > 0);
271 l = g_queue_get_length (q);
273 g_assert (qinf->length == q->length);
274 g_assert (qinf->length == l);
279 g_assert (qinf->tail == q->head);
280 g_assert (qinf->head == q->tail);
281 g_assert (qinf->length == q->length);
282 qinf->tail = q->tail;
283 qinf->head = q->head;
287 QueueInfo *random_queue = RANDOM_QUEUE();
288 GQueue *new_queue = g_queue_copy (random_queue->queue);
290 g_queue_free (qinf->queue);
291 q = qinf->queue = new_queue;
292 qinf->head = new_queue->head;
293 qinf->tail = g_list_last (new_queue->head);
294 qinf->length = new_queue->length;
305 gboolean find_existing = rnd_bool ();
306 int first = find_max (q);
307 int second = find_min (q);
310 find_existing = FALSE;
319 g_assert (g_queue_find (q, GINT_TO_POINTER (first)));
320 g_assert (g_queue_find (q, GINT_TO_POINTER (second)));
324 g_assert (!g_queue_find (q, GINT_TO_POINTER (first)));
325 g_assert (!g_queue_find (q, GINT_TO_POINTER (second)));
333 if (!g_queue_is_empty (q))
335 int max = find_max (q);
336 int min = find_min (q);
337 g_queue_remove_all (q, GINT_TO_POINTER (max));
339 g_queue_remove_all (q, GINT_TO_POINTER (min));
341 g_queue_push_head (q, GINT_TO_POINTER (max));
343 g_queue_push_head (q, GINT_TO_POINTER (min));
344 qinf->length = q->length;
349 g_queue_sort (q, compare_int, NULL);
353 qinf->head = g_queue_find (q, GINT_TO_POINTER (find_min(q)));
354 qinf->tail = g_queue_find (q, GINT_TO_POINTER (find_max(q)));
356 g_assert (qinf->tail == q->tail);
361 int x = g_random_int_range (0, 435435);
362 g_queue_push_head (q, GINT_TO_POINTER (x));
364 qinf->tail = qinf->head = q->head;
366 qinf->head = qinf->head->prev;
372 int x = g_random_int_range (0, 236546);
373 g_queue_push_tail (q, GINT_TO_POINTER (x));
375 qinf->tail = qinf->head = q->head;
377 qinf->tail = qinf->tail->next;
383 int pos = get_random_position (q, TRUE);
384 int x = g_random_int_range (0, 236546);
385 g_queue_push_nth (q, GINT_TO_POINTER (x), pos);
386 if (qinf->head && qinf->head->prev)
387 qinf->head = qinf->head->prev;
389 qinf->head = q->head;
390 if (qinf->tail && qinf->tail->next)
391 qinf->tail = qinf->tail->next;
393 qinf->tail = g_list_last (qinf->head);
399 qinf->head = qinf->head->next;
402 qinf->length = (qinf->length == 0)? 0 : qinf->length - 1;
403 g_queue_pop_head (q);
407 qinf->tail = qinf->tail->prev;
410 qinf->length = (qinf->length == 0)? 0 : qinf->length - 1;
411 g_queue_pop_tail (q);
414 if (!g_queue_is_empty (q))
416 int n = get_random_position (q, TRUE);
417 gpointer elm = g_queue_peek_nth (q, n);
419 if (n == q->length - 1)
420 qinf->tail = qinf->tail->prev;
423 qinf->head = qinf->head->next;
425 if (n >= 0 && n < q->length)
428 g_assert (elm == g_queue_pop_nth (q, n));
433 g_assert (qinf->head->data == g_queue_peek_head (q));
435 g_assert (g_queue_peek_head (q) == NULL);
439 g_assert (qinf->tail->data == g_queue_peek_tail (q));
441 g_assert (g_queue_peek_tail (q) == NULL);
444 if (g_queue_is_empty (q))
446 for (j = -10; j < 10; ++j)
447 g_assert (g_queue_peek_nth (q, j) == NULL);
452 int n = get_random_position (q, TRUE);
453 if (n < 0 || n >= q->length)
455 g_assert (g_queue_peek_nth (q, n) == NULL);
460 for (j = 0; j < n; ++j)
463 g_assert (list->data == g_queue_peek_nth (q, n));
470 int x = g_random_int_range (0, 386538);
474 g_queue_remove_all (q, GINT_TO_POINTER (x));
476 g_queue_push_tail (q, GINT_TO_POINTER (x));
478 g_queue_sort (q, compare_int, NULL);
482 for (list = q->head; list != NULL; list = list->next)
484 if (list->data == GINT_TO_POINTER (x))
489 g_assert (g_queue_index (q, GINT_TO_POINTER (x)) ==
490 g_queue_link_index (q, list));
491 g_assert (g_queue_link_index (q, list) == n);
493 qinf->head = q->head;
494 qinf->tail = q->tail;
495 qinf->length = q->length;
499 if (!g_queue_is_empty (q))
500 g_queue_remove (q, qinf->tail->data);
501 if (!g_queue_is_empty (q))
502 g_queue_remove (q, qinf->head->data);
503 if (!g_queue_is_empty (q))
504 g_queue_remove (q, g_queue_peek_nth (q, get_random_position (q, TRUE)));
506 qinf->head = q->head;
507 qinf->tail = q->tail;
508 qinf->length = q->length;
511 if (!g_queue_is_empty (q))
512 g_queue_remove_all (q, qinf->tail->data);
513 if (!g_queue_is_empty (q))
514 g_queue_remove_all (q, qinf->head->data);
515 if (!g_queue_is_empty (q))
516 g_queue_remove_all (q, g_queue_peek_nth (q, get_random_position (q, TRUE)));
518 qinf->head = q->head;
519 qinf->tail = q->tail;
520 qinf->length = q->length;
523 if (!g_queue_is_empty (q))
525 gpointer x = GINT_TO_POINTER (g_random_int_range (0, 386538));
527 g_queue_insert_before (q, qinf->tail, x);
528 g_queue_insert_before (q, qinf->head, x);
529 g_queue_insert_before (q, g_queue_find (q, x), x);
531 qinf->head = q->head;
532 qinf->tail = q->tail;
533 qinf->length = q->length;
536 if (!g_queue_is_empty (q))
538 gpointer x = GINT_TO_POINTER (g_random_int_range (0, 386538));
540 g_queue_insert_after (q, qinf->tail, x);
541 g_queue_insert_after (q, qinf->head, x);
542 g_queue_insert_after (q, g_queue_find (q, x), x);
544 qinf->head = q->head;
545 qinf->tail = q->tail;
546 qinf->length = q->length;
550 int max = find_max (q);
551 int min = find_min (q);
553 if (g_queue_is_empty (q))
559 g_queue_sort (q, compare_int, NULL);
561 g_queue_insert_sorted (q, GINT_TO_POINTER (max + 1), compare_int, NULL);
563 g_assert (GPOINTER_TO_INT (q->tail->data) == max + 1);
564 g_queue_insert_sorted (q, GINT_TO_POINTER (min - 1), compare_int, NULL);
566 g_assert (GPOINTER_TO_INT (q->head->data) == min - 1);
567 qinf->head = q->head;
568 qinf->tail = q->tail;
569 qinf->length = q->length;
574 GList *link = g_list_prepend (NULL, GINT_TO_POINTER (i));
575 g_queue_push_head_link (q, link);
584 GList *link = g_list_prepend (NULL, GINT_TO_POINTER (i));
585 g_queue_push_tail_link (q, link);
594 GList *link = g_list_prepend (NULL, GINT_TO_POINTER (i));
595 gint n = get_random_position (q, TRUE);
596 g_queue_push_nth_link (q, n, link);
598 if (qinf->head && qinf->head->prev)
599 qinf->head = qinf->head->prev;
601 qinf->head = q->head;
602 if (qinf->tail && qinf->tail->next)
603 qinf->tail = qinf->tail->next;
605 qinf->tail = g_list_last (qinf->head);
610 if (!g_queue_is_empty (q))
612 qinf->head = qinf->head->next;
616 g_list_free (g_queue_pop_head_link (q));
620 if (!g_queue_is_empty (q))
622 qinf->tail = qinf->tail->prev;
626 g_list_free (g_queue_pop_tail_link (q));
630 if (g_queue_is_empty (q))
631 g_assert (g_queue_pop_nth_link (q, 200) == NULL);
634 int n = get_random_position (q, FALSE);
636 if (n == g_queue_get_length (q) - 1)
637 qinf->tail = qinf->tail->prev;
640 qinf->head = qinf->head->next;
644 g_list_free (g_queue_pop_nth_link (q, n));
648 if (g_queue_is_empty (q))
649 g_assert (g_queue_peek_head_link (q) == NULL);
651 g_assert (g_queue_peek_head_link (q) == qinf->head);
654 if (g_queue_is_empty (q))
655 g_assert (g_queue_peek_tail_link (q) == NULL);
657 g_assert (g_queue_peek_tail_link (q) == qinf->tail);
660 if (g_queue_is_empty(q))
661 g_assert (g_queue_peek_nth_link (q, 1000) == NULL);
664 gint n = get_random_position (q, FALSE);
668 for (j = 0; j < n; ++j)
671 g_assert (g_queue_peek_nth_link (q, n) == link);
675 if (!g_queue_is_empty (q))
677 gint n = g_random_int_range (0, g_queue_get_length (q));
681 for (j = 0; j < n; ++j)
684 g_queue_unlink (q, link);
689 qinf->head = q->head;
690 qinf->tail = q->tail;
695 if (!g_queue_is_empty (q))
697 gint n = g_random_int_range (0, g_queue_get_length (q));
701 for (j = 0; j < n; ++j)
704 g_queue_delete_link (q, link);
707 qinf->head = q->head;
708 qinf->tail = q->tail;
714 g_assert_not_reached();
718 if (qinf->head != q->head ||
719 qinf->tail != q->tail ||
720 qinf->length != q->length)
721 g_print ("op: %d\n", op);
723 g_assert (qinf->head == q->head);
724 g_assert (qinf->tail == q->tail);
725 g_assert (qinf->length == q->length);
727 for (j = 0; j < N_QUEUES; ++j)
728 check_integrity (queues[j].queue);
731 for (i = 0; i < N_QUEUES; ++i)
732 g_queue_free (queues[i].queue);
736 remove_item (gpointer data, gpointer q)
740 g_queue_remove (queue, data);
752 g_assert (g_queue_is_empty (q));
753 g_queue_push_head (q, GINT_TO_POINTER (2));
755 g_assert (g_queue_peek_head (q) == GINT_TO_POINTER (2));
757 g_assert (!g_queue_is_empty (q));
759 g_assert_cmpint (g_list_length (q->head), ==, 1);
760 g_assert (q->head == q->tail);
761 g_queue_push_head (q, GINT_TO_POINTER (1));
763 g_assert (q->head->next == q->tail);
764 g_assert (q->tail->prev == q->head);
765 g_assert_cmpint (g_list_length (q->head), ==, 2);
767 g_assert (q->tail->data == GINT_TO_POINTER (2));
768 g_assert (q->head->data == GINT_TO_POINTER (1));
770 g_queue_push_tail (q, GINT_TO_POINTER (3));
771 g_assert_cmpint (g_list_length (q->head), ==, 3);
772 g_assert (q->head->data == GINT_TO_POINTER (1));
773 g_assert (q->head->next->data == GINT_TO_POINTER (2));
774 g_assert (q->head->next->next == q->tail);
775 g_assert (q->head->next == q->tail->prev);
776 g_assert (q->tail->data == GINT_TO_POINTER (3));
777 g_queue_push_tail (q, GINT_TO_POINTER (4));
779 g_assert_cmpint (g_list_length (q->head), ==, 4);
780 g_assert (q->head->data == GINT_TO_POINTER (1));
781 g_assert (g_queue_peek_tail (q) == GINT_TO_POINTER (4));
782 g_queue_push_tail (q, GINT_TO_POINTER (5));
784 g_assert_cmpint (g_list_length (q->head), ==, 5);
785 g_assert (g_queue_is_empty (q) == FALSE);
787 g_assert_cmpint (q->length, ==, 5);
788 g_assert (q->head->prev == NULL);
789 g_assert (q->head->data == GINT_TO_POINTER (1));
790 g_assert (q->head->next->data == GINT_TO_POINTER (2));
791 g_assert (q->head->next->next->data == GINT_TO_POINTER (3));
792 g_assert (q->head->next->next->next->data == GINT_TO_POINTER (4));
793 g_assert (q->head->next->next->next->next->data == GINT_TO_POINTER (5));
794 g_assert (q->head->next->next->next->next->next == NULL);
795 g_assert (q->head->next->next->next->next == q->tail);
796 g_assert (q->tail->data == GINT_TO_POINTER (5));
797 g_assert (q->tail->prev->data == GINT_TO_POINTER (4));
798 g_assert (q->tail->prev->prev->data == GINT_TO_POINTER (3));
799 g_assert (q->tail->prev->prev->prev->data == GINT_TO_POINTER (2));
800 g_assert (q->tail->prev->prev->prev->prev->data == GINT_TO_POINTER (1));
801 g_assert (q->tail->prev->prev->prev->prev->prev == NULL);
802 g_assert (q->tail->prev->prev->prev->prev == q->head);
803 g_assert (g_queue_peek_tail (q) == GINT_TO_POINTER (5));
804 g_assert (g_queue_peek_head (q) == GINT_TO_POINTER (1));
805 g_assert (g_queue_pop_head (q) == GINT_TO_POINTER (1));
807 g_assert_cmpint (g_list_length (q->head), ==, 4);
808 g_assert_cmpint (q->length, ==, 4);
809 g_assert (g_queue_pop_tail (q) == GINT_TO_POINTER (5));
811 g_assert_cmpint (g_list_length (q->head), ==, 3);
813 node = g_queue_pop_head_link (q);
814 g_assert (node->data == GINT_TO_POINTER (2));
815 g_list_free_1 (node);
818 g_assert_cmpint (g_list_length (q->head), ==, 2);
819 g_assert (g_queue_pop_tail (q) == GINT_TO_POINTER (4));
821 g_assert_cmpint (g_list_length (q->head), ==, 1);
822 node = g_queue_pop_head_link (q);
823 g_assert (node->data == GINT_TO_POINTER (3));
824 g_list_free_1 (node);
826 g_assert_cmpint (g_list_length (q->head), ==, 0);
827 g_assert (g_queue_pop_tail (q) == NULL);
829 g_assert_cmpint (g_list_length (q->head), ==, 0);
830 g_assert (g_queue_pop_head (q) == NULL);
832 g_assert_cmpint (g_list_length (q->head), ==, 0);
833 g_assert (g_queue_is_empty (q));
836 g_queue_push_head (q, GINT_TO_POINTER (1));
838 g_assert_cmpint (g_list_length (q->head), ==, 1);
839 g_assert_cmpint (q->length, ==, 1);
840 g_queue_push_head (q, GINT_TO_POINTER (2));
842 g_assert_cmpint (g_list_length (q->head), ==, 2);
843 g_assert_cmpint (q->length, ==, 2);
844 g_queue_push_head (q, GINT_TO_POINTER (3));
846 g_assert_cmpint (g_list_length (q->head), ==, 3);
847 g_assert_cmpint (q->length, ==, 3);
848 g_queue_push_head (q, GINT_TO_POINTER (4));
850 g_assert_cmpint (g_list_length (q->head), ==, 4);
851 g_assert_cmpint (q->length, ==, 4);
852 g_queue_push_head (q, GINT_TO_POINTER (5));
854 g_assert_cmpint (g_list_length (q->head), ==, 5);
855 g_assert_cmpint (q->length, ==, 5);
856 g_assert (g_queue_pop_head (q) == GINT_TO_POINTER (5));
858 g_assert_cmpint (g_list_length (q->head), ==, 4);
860 g_assert (node == g_queue_pop_tail_link (q));
862 g_list_free_1 (node);
863 g_assert_cmpint (g_list_length (q->head), ==, 3);
864 data = q->head->data;
865 g_assert (data == g_queue_pop_head (q));
867 g_assert_cmpint (g_list_length (q->head), ==, 2);
868 g_assert (g_queue_pop_tail (q) == GINT_TO_POINTER (2));
870 g_assert_cmpint (g_list_length (q->head), ==, 1);
871 g_assert (q->head == q->tail);
872 g_assert (g_queue_pop_tail (q) == GINT_TO_POINTER (3));
874 g_assert_cmpint (g_list_length (q->head), ==, 0);
875 g_assert (g_queue_pop_head (q) == NULL);
877 g_assert (g_queue_pop_head_link (q) == NULL);
879 g_assert_cmpint (g_list_length (q->head), ==, 0);
880 g_assert (g_queue_pop_tail_link (q) == NULL);
882 g_assert_cmpint (g_list_length (q->head), ==, 0);
886 g_assert_cmpint (g_list_length (q->head), ==, 0);
897 q2 = g_queue_copy (q);
899 check_integrity (q2);
900 g_assert_cmpint (g_list_length (q->head), ==, 0);
901 g_assert_cmpint (g_list_length (q2->head), ==, 0);
902 g_queue_sort (q, compare_int, NULL);
903 check_integrity (q2);
905 g_queue_sort (q2, compare_int, NULL);
906 check_integrity (q2);
909 for (i = 0; i < 200; ++i)
911 g_queue_push_nth (q, GINT_TO_POINTER (i), i);
912 g_assert (g_queue_find (q, GINT_TO_POINTER (i)));
914 check_integrity (q2);
917 for (i = 0; i < 200; ++i)
919 g_queue_remove (q, GINT_TO_POINTER (i));
921 check_integrity (q2);
924 for (i = 0; i < 200; ++i)
926 GList *l = g_list_prepend (NULL, GINT_TO_POINTER (i));
928 g_queue_push_nth_link (q, i, l);
930 check_integrity (q2);
933 check_integrity (q2);
937 q2 = g_queue_copy (q);
939 g_queue_foreach (q2, remove_item, q2);
940 check_integrity (q2);
948 test_off_by_one (void)
955 g_queue_push_tail (q, GINT_TO_POINTER (1234));
957 node = g_queue_peek_tail_link (q);
958 g_assert (node != NULL && node->data == GINT_TO_POINTER (1234));
959 node = g_queue_peek_nth_link (q, g_queue_get_length (q));
960 g_assert (node == NULL);
961 node = g_queue_peek_nth_link (q, g_queue_get_length (q) - 1);
962 g_assert (node->data == GINT_TO_POINTER (1234));
963 node = g_queue_pop_nth_link (q, g_queue_get_length (q));
964 g_assert (node == NULL);
965 node = g_queue_pop_nth_link (q, g_queue_get_length (q) - 1);
966 g_assert (node != NULL && node->data == GINT_TO_POINTER (1234));
967 g_list_free_1 (node);
973 find_custom (gconstpointer a, gconstpointer b)
975 return GPOINTER_TO_INT (a) - GPOINTER_TO_INT (b);
979 test_find_custom (void)
985 g_queue_push_tail (q, GINT_TO_POINTER (1234));
986 g_queue_push_tail (q, GINT_TO_POINTER (1));
987 g_queue_push_tail (q, GINT_TO_POINTER (2));
988 node = g_queue_find_custom (q, GINT_TO_POINTER (1), find_custom);
989 g_assert (node != NULL);
990 node = g_queue_find_custom (q, GINT_TO_POINTER (2), find_custom);
991 g_assert (node != NULL);
992 node = g_queue_find_custom (q, GINT_TO_POINTER (3), find_custom);
993 g_assert (node == NULL);
1002 GQueue q2 = G_QUEUE_INIT;
1006 check_integrity (&q);
1007 g_assert (g_queue_is_empty (&q));
1009 check_integrity (&q2);
1010 g_assert (g_queue_is_empty (&q2));
1019 g_queue_push_tail (q, GINT_TO_POINTER (1234));
1020 g_queue_push_tail (q, GINT_TO_POINTER (1));
1021 g_queue_push_tail (q, GINT_TO_POINTER (2));
1022 g_assert_cmpint (g_queue_get_length (q), ==, 3);
1025 check_integrity (q);
1026 g_assert (g_queue_is_empty (q));
1038 free_func (gpointer data)
1040 QueueItem *item = data;
1050 item = g_slice_new (QueueItem);
1051 item->freed = FALSE;
1058 test_free_full (void)
1060 QueueItem *one, *two, *three;
1061 GQueue *queue = NULL;
1063 queue = g_queue_new();
1064 g_queue_push_tail (queue, one = new_item (1));
1065 g_queue_push_tail (queue, two = new_item (2));
1066 g_queue_push_tail (queue, three = new_item (3));
1067 g_assert (!one->freed);
1068 g_assert (!two->freed);
1069 g_assert (!three->freed);
1070 g_queue_free_full (queue, free_func);
1071 g_assert (one->freed);
1072 g_assert (two->freed);
1073 g_assert (three->freed);
1074 g_slice_free (QueueItem, one);
1075 g_slice_free (QueueItem, two);
1076 g_slice_free (QueueItem, three);
1080 int main (int argc, char *argv[])
1085 g_test_init (&argc, &argv, NULL);
1087 g_test_add_func ("/queue/basic", test_basic);
1088 g_test_add_func ("/queue/copy", test_copy);
1089 g_test_add_func ("/queue/off-by-one", test_off_by_one);
1090 g_test_add_func ("/queue/find-custom", test_find_custom);
1091 g_test_add_func ("/queue/static", test_static);
1092 g_test_add_func ("/queue/clear", test_clear);
1093 g_test_add_func ("/queue/free-full", test_free_full);
1095 seed = g_test_rand_int_range (0, G_MAXINT);
1096 path = g_strdup_printf ("/queue/random/seed:%u", seed);
1097 g_test_add_data_func (path, GUINT_TO_POINTER (seed), random_test);
1100 return g_test_run ();