14 g_assert (g_queue_is_empty (q) == TRUE);
16 g_queue_push_head (q, GINT_TO_POINTER (2));
17 g_assert (g_queue_peek_head (q) == GINT_TO_POINTER (2));
18 g_assert (g_queue_is_empty (q) == FALSE);
19 g_assert (g_list_length (q->head) == 1);
20 g_assert (q->head == q->tail);
21 g_queue_push_head (q, GINT_TO_POINTER (1));
22 g_assert (q->head->next == q->tail);
23 g_assert (q->tail->prev == q->head);
24 g_assert (g_list_length (q->head) == 2);
25 g_assert (q->tail->data == GINT_TO_POINTER (2));
26 g_assert (q->head->data == GINT_TO_POINTER (1));
27 g_queue_push_tail (q, GINT_TO_POINTER (3));
28 g_assert (g_list_length (q->head) == 3);
29 g_assert (q->head->data == GINT_TO_POINTER (1));
30 g_assert (q->head->next->data == GINT_TO_POINTER (2));
31 g_assert (q->head->next->next == q->tail);
32 g_assert (q->head->next == q->tail->prev);
33 g_assert (q->tail->data == GINT_TO_POINTER (3));
34 g_queue_push_tail (q, GINT_TO_POINTER (4));
35 g_assert (g_list_length (q->head) == 4);
36 g_assert (q->head->data == GINT_TO_POINTER (1));
37 g_assert (g_queue_peek_tail (q) == GINT_TO_POINTER (4));
38 g_queue_push_tail (q, GINT_TO_POINTER (5));
39 g_assert (g_list_length (q->head) == 5);
41 g_assert (g_queue_is_empty (q) == FALSE);
43 g_assert (q->length == 5);
44 g_assert (q->head->prev == NULL);
45 g_assert (q->head->data == GINT_TO_POINTER (1));
46 g_assert (q->head->next->data == GINT_TO_POINTER (2));
47 g_assert (q->head->next->next->data == GINT_TO_POINTER (3));
48 g_assert (q->head->next->next->next->data == GINT_TO_POINTER (4));
49 g_assert (q->head->next->next->next->next->data == GINT_TO_POINTER (5));
50 g_assert (q->head->next->next->next->next->next == NULL);
51 g_assert (q->head->next->next->next->next == q->tail);
52 g_assert (q->tail->data == GINT_TO_POINTER (5));
53 g_assert (q->tail->prev->data == GINT_TO_POINTER (4));
54 g_assert (q->tail->prev->prev->data == GINT_TO_POINTER (3));
55 g_assert (q->tail->prev->prev->prev->data == GINT_TO_POINTER (2));
56 g_assert (q->tail->prev->prev->prev->prev->data == GINT_TO_POINTER (1));
57 g_assert (q->tail->prev->prev->prev->prev->prev == NULL);
58 g_assert (q->tail->prev->prev->prev->prev == q->head);
59 g_assert (g_queue_peek_tail (q) == GINT_TO_POINTER (5));
60 g_assert (g_queue_peek_head (q) == GINT_TO_POINTER (1));
62 g_assert (g_queue_pop_head (q) == GINT_TO_POINTER (1));
63 g_assert (g_list_length (q->head) == 4 && q->length == 4);
64 g_assert (g_queue_pop_tail (q) == GINT_TO_POINTER (5));
65 g_assert (g_list_length (q->head) == 3);
66 g_assert (g_queue_pop_head_link (q)->data == GINT_TO_POINTER (2));
67 g_assert (g_list_length (q->head) == 2);
68 g_assert (g_queue_pop_tail (q) == GINT_TO_POINTER (4));
69 g_assert (g_list_length (q->head) == 1);
70 g_assert (g_queue_pop_head_link (q)->data == GINT_TO_POINTER (3));
71 g_assert (g_list_length (q->head) == 0);
72 g_assert (g_queue_pop_tail (q) == NULL);
73 g_assert (g_list_length (q->head) == 0);
74 g_assert (g_queue_pop_head (q) == NULL);
75 g_assert (g_list_length (q->head) == 0);
77 g_assert (g_queue_is_empty (q) == TRUE);
79 /************************/
81 g_queue_push_head (q, GINT_TO_POINTER (1));
82 g_assert (g_list_length (q->head) == 1 && 1 == q->length);
83 g_queue_push_head (q, GINT_TO_POINTER (2));
84 g_assert (g_list_length (q->head) == 2 && 2 == q->length);
85 g_queue_push_head (q, GINT_TO_POINTER (3));
86 g_assert (g_list_length (q->head) == 3 && 3 == q->length);
87 g_queue_push_head (q, GINT_TO_POINTER (4));
88 g_assert (g_list_length (q->head) == 4 && 4 == q->length);
89 g_queue_push_head (q, GINT_TO_POINTER (5));
90 g_assert (g_list_length (q->head) == 5 && 5 == q->length);
92 g_assert (g_queue_pop_head (q) == GINT_TO_POINTER (5));
93 g_assert (g_list_length (q->head) == 4);
95 g_assert (node == g_queue_pop_tail_link (q));
96 g_assert (g_list_length (q->head) == 3);
98 g_assert (data == g_queue_pop_head (q));
99 g_assert (g_list_length (q->head) == 2);
100 g_assert (g_queue_pop_tail (q) == GINT_TO_POINTER (2));
101 g_assert (g_list_length (q->head) == 1);
102 g_assert (q->head == q->tail);
103 g_assert (g_queue_pop_tail (q) == GINT_TO_POINTER (3));
104 g_assert (g_list_length (q->head) == 0);
105 g_assert (g_queue_pop_head (q) == NULL);
106 g_assert (g_queue_pop_head_link (q) == NULL);
107 g_assert (g_list_length (q->head) == 0);
108 g_assert (g_queue_pop_tail_link (q) == NULL);
109 g_assert (g_list_length (q->head) == 0);