9 GQueue
*queue
= g_queue_new ();
11 g_queue_push_head (queue
, "foo");
12 g_queue_push_head (queue
, "bar");
13 g_queue_push_head (queue
, "baz");
15 if (queue
->length
!= 3)
16 return FAILED ("push failed");
25 GQueue
*queue
= g_queue_new ();
28 g_queue_push_head (queue
, "foo");
29 g_queue_push_head (queue
, "bar");
30 g_queue_push_head (queue
, "baz");
32 data
= g_queue_pop_head (queue
);
33 if (strcmp ("baz", data
))
34 return FAILED ("expect baz.");
36 data
= g_queue_pop_head (queue
);
37 if (strcmp ("bar", data
))
38 return FAILED ("expect bar.");
40 data
= g_queue_pop_head (queue
);
41 if (strcmp ("foo", data
))
42 return FAILED ("expect foo.");
44 if (g_queue_is_empty (queue
) == FALSE
)
45 return FAILED ("expect is_empty.");
47 if (queue
->length
!= 0)
48 return FAILED ("expect 0 length .");
57 GQueue
*queue
= g_queue_new ();
59 if (queue
->length
!= 0)
60 return FAILED ("expect length == 0");
62 if (queue
->head
!= NULL
)
63 return FAILED ("expect head == NULL");
65 if (queue
->tail
!= NULL
)
66 return FAILED ("expect tail == NULL");
73 test_queue_is_empty ()
75 GQueue
*queue
= g_queue_new ();
77 if (g_queue_is_empty (queue
) == FALSE
)
78 return FAILED ("new queue should be empty");
80 g_queue_push_head (queue
, "foo");
82 if (g_queue_is_empty (queue
) == TRUE
)
83 return FAILED ("expected TRUE");
90 static Test queue_tests
[] = {
91 { "push", test_queue_push
},
92 { "pop", test_queue_pop
},
93 { "new", test_queue_new
},
94 {"is_empty", test_queue_is_empty
},
98 DEFINE_TEST_GROUP_INIT(queue_tests_init
, queue_tests
)