1 /***
2 This file is part of PulseAudio.
3
4 PulseAudio is free software; you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as published
6 by the Free Software Foundation; either version 2.1 of the License,
7 or (at your option) any later version.
8
9 PulseAudio is distributed in the hope that it will be useful, but
10 WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public License
15 along with PulseAudio; if not, see <http://www.gnu.org/licenses/>.
16 ***/
17
18 #ifdef HAVE_CONFIG_H
19 #include <config.h>
20 #endif
21
22 #include <assert.h>
23 #include <stdlib.h>
24 #include <unistd.h>
25
26 #include <check.h>
27
28 #include <pulsecore/queue.h>
29 #include <pulsecore/log.h>
30 #include <pulsecore/macro.h>
31
START_TEST(queue_test)32 START_TEST (queue_test) {
33 pa_queue *q;
34
35 q = pa_queue_new();
36 fail_unless(q != NULL);
37
38 fail_unless(pa_queue_isempty(q));
39
40 pa_queue_push(q, (void*) "eins");
41 pa_log("%s\n", (char*) pa_queue_pop(q));
42
43 fail_unless(pa_queue_isempty(q));
44
45 pa_queue_push(q, (void*) "zwei");
46 pa_queue_push(q, (void*) "drei");
47 pa_queue_push(q, (void*) "vier");
48
49 pa_log("%s\n", (char*) pa_queue_pop(q));
50 pa_log("%s\n", (char*) pa_queue_pop(q));
51
52 pa_queue_push(q, (void*) "fuenf");
53
54 pa_log("%s\n", (char*) pa_queue_pop(q));
55 pa_log("%s\n", (char*) pa_queue_pop(q));
56
57 fail_unless(pa_queue_isempty(q));
58
59 pa_queue_push(q, (void*) "sechs");
60 pa_queue_push(q, (void*) "sieben");
61
62 pa_queue_free(q, NULL);
63 }
64 END_TEST
65
main(int argc,char * argv[])66 int main(int argc, char *argv[]) {
67 int failed = 0;
68 Suite *s;
69 TCase *tc;
70 SRunner *sr;
71
72 s = suite_create("Queue");
73 tc = tcase_create("queue");
74 tcase_add_test(tc, queue_test);
75 suite_add_tcase(s, tc);
76
77 sr = srunner_create(s);
78 srunner_run_all(sr, CK_NORMAL);
79 failed = srunner_ntests_failed(sr);
80 srunner_free(sr);
81
82 return (failed == 0) ? EXIT_SUCCESS : EXIT_FAILURE;
83 }
84