3 #include <winpr/tchar.h>
4 #include <winpr/collections.h>
6 int TestArrayList(
int argc,
char* argv[])
10 const size_t elemsToInsert = 10;
15 wArrayList* arrayList = ArrayList_New(TRUE);
19 for (
size_t index = 0; index < elemsToInsert; index++)
21 if (!ArrayList_Append(arrayList, (
void*)index))
25 size_t count = ArrayList_Count(arrayList);
27 printf(
"ArrayList count: %" PRIuz
"\n", count);
29 SSIZE_T index = ArrayList_IndexOf(arrayList, (
void*)(
size_t)6, -1, -1);
31 printf(
"ArrayList index: %" PRIdz
"\n", index);
36 ArrayList_Insert(arrayList, 5, (
void*)(
size_t)100);
38 index = ArrayList_IndexOf(arrayList, (
void*)(
size_t)6, -1, -1);
39 printf(
"ArrayList index: %" PRIdz
"\n", index);
44 ArrayList_Remove(arrayList, (
void*)(
size_t)100);
46 rc = ArrayList_IndexOf(arrayList, (
void*)(
size_t)6, -1, -1);
47 printf(
"ArrayList index: %d\n", rc);
52 for (
size_t index = 0; index < elemsToInsert; index++)
54 val = (size_t)ArrayList_GetItem(arrayList, 0);
55 if (!ArrayList_RemoveAt(arrayList, 0))
59 printf(
"ArrayList: shifted %" PRIdz
" entries, expected value %" PRIdz
", got %" PRIdz
66 rc = ArrayList_IndexOf(arrayList, (
void*)elemsToInsert, -1, -1);
67 printf(
"ArrayList index: %d\n", rc);
71 count = ArrayList_Count(arrayList);
72 printf(
"ArrayList count: %" PRIuz
"\n", count);
76 ArrayList_Clear(arrayList);
77 ArrayList_Free(arrayList);