FreeRDP
TestQueue.c
1 
2 #include <winpr/crt.h>
3 #include <winpr/tchar.h>
4 #include <winpr/collections.h>
5 
6 int TestQueue(int argc, char* argv[])
7 {
8  size_t item = 0;
9  size_t count = 0;
10  wQueue* queue = NULL;
11 
12  WINPR_UNUSED(argc);
13  WINPR_UNUSED(argv);
14 
15  queue = Queue_New(TRUE, -1, -1);
16  if (!queue)
17  return -1;
18 
19  for (size_t index = 1; index <= 10; index++)
20  {
21  Queue_Enqueue(queue, (void*)index);
22  }
23 
24  count = Queue_Count(queue);
25  printf("queue count: %" PRIuz "\n", count);
26 
27  for (size_t index = 1; index <= 10; index++)
28  {
29  item = (size_t)Queue_Dequeue(queue);
30 
31  if (item != index)
32  return -1;
33  }
34 
35  count = Queue_Count(queue);
36  printf("queue count: %" PRIuz "\n", count);
37 
38  Queue_Enqueue(queue, (void*)(size_t)1);
39  Queue_Enqueue(queue, (void*)(size_t)2);
40  Queue_Enqueue(queue, (void*)(size_t)3);
41 
42  Queue_Dequeue(queue);
43  Queue_Dequeue(queue);
44 
45  Queue_Enqueue(queue, (void*)(size_t)4);
46  Queue_Enqueue(queue, (void*)(size_t)5);
47  Queue_Enqueue(queue, (void*)(size_t)6);
48 
49  Queue_Dequeue(queue);
50  Queue_Dequeue(queue);
51  Queue_Dequeue(queue);
52  Queue_Dequeue(queue);
53 
54  Queue_Clear(queue);
55  Queue_Free(queue);
56 
57  return 0;
58 }