3 #include <winpr/tchar.h>
4 #include <winpr/collections.h>
6 int TestLinkedList(
int argc,
char* argv[])
11 wLinkedList* list = LinkedList_New();
15 if (!LinkedList_AddFirst(list, (
void*)(
size_t)1))
17 if (!LinkedList_AddLast(list, (
void*)(
size_t)2))
19 if (!LinkedList_AddLast(list, (
void*)(
size_t)3))
21 size_t count = LinkedList_Count(list);
25 printf(
"LinkedList_Count: expected 3, actual: %" PRIuz
"\n", count);
29 LinkedList_Enumerator_Reset(list);
31 while (LinkedList_Enumerator_MoveNext(list))
33 printf(
"\t%p\n", LinkedList_Enumerator_Current(list));
37 printf(
"LinkedList First: %p Last: %p\n", LinkedList_First(list), LinkedList_Last(list));
38 LinkedList_RemoveFirst(list);
39 LinkedList_RemoveLast(list);
40 count = LinkedList_Count(list);
44 printf(
"LinkedList_Count: expected 1, actual: %" PRIuz
"\n", count);
48 LinkedList_Enumerator_Reset(list);
50 while (LinkedList_Enumerator_MoveNext(list))
52 printf(
"\t%p\n", LinkedList_Enumerator_Current(list));
56 printf(
"LinkedList First: %p Last: %p\n", LinkedList_First(list), LinkedList_Last(list));
57 LinkedList_RemoveFirst(list);
58 LinkedList_RemoveLast(list);
59 count = LinkedList_Count(list);
63 printf(
"LinkedList_Count: expected 0, actual: %" PRIuz
"\n", count);
67 if (!LinkedList_AddFirst(list, (
void*)(
size_t)4))
69 if (!LinkedList_AddLast(list, (
void*)(
size_t)5))
71 if (!LinkedList_AddLast(list, (
void*)(
size_t)6))
73 count = LinkedList_Count(list);
77 printf(
"LinkedList_Count: expected 3, actual: %" PRIuz
"\n", count);
81 LinkedList_Enumerator_Reset(list);
83 while (LinkedList_Enumerator_MoveNext(list))
85 printf(
"\t%p\n", LinkedList_Enumerator_Current(list));
89 printf(
"LinkedList First: %p Last: %p\n", LinkedList_First(list), LinkedList_Last(list));
90 if (!LinkedList_Remove(list, (
void*)(
size_t)5))
92 LinkedList_Enumerator_Reset(list);
94 while (LinkedList_Enumerator_MoveNext(list))
96 printf(
"\t%p\n", LinkedList_Enumerator_Current(list));
100 printf(
"LinkedList First: %p Last: %p\n", LinkedList_First(list), LinkedList_Last(list));
101 LinkedList_Free(list);
104 list = LinkedList_New();
107 LinkedList_Enumerator_Reset(list);
109 while (LinkedList_Enumerator_MoveNext(list))
111 printf(
"\terror: %p\n", LinkedList_Enumerator_Current(list));
115 LinkedList_Free(list);
117 list = LinkedList_New();
120 if (!LinkedList_AddFirst(list, (
void*)(
size_t)4))
122 if (!LinkedList_AddLast(list, (
void*)(
size_t)5))
124 if (!LinkedList_AddLast(list, (
void*)(
size_t)6))
127 while (LinkedList_Enumerator_MoveNext(list))
129 printf(
"\t%p\n", LinkedList_Enumerator_Current(list));
133 LinkedList_Free(list);