3 #include <winpr/tchar.h>
4 #include <winpr/collections.h>
6 int TestArrayList(
int argc,
char* argv[])
11 const size_t elemsToInsert = 10;
16 wArrayList* arrayList = ArrayList_New(TRUE);
20 for (
size_t index = 0; index < elemsToInsert; index++)
22 if (!ArrayList_Append(arrayList, (
void*)index))
26 size_t count = ArrayList_Count(arrayList);
28 printf(
"ArrayList count: %" PRIuz
"\n", count);
30 SSIZE_T index = ArrayList_IndexOf(arrayList, (
void*)(
size_t)6, -1, -1);
32 printf(
"ArrayList index: %" PRIdz
"\n", index);
37 ArrayList_Insert(arrayList, 5, (
void*)(
size_t)100);
39 index = ArrayList_IndexOf(arrayList, (
void*)(
size_t)6, -1, -1);
40 printf(
"ArrayList index: %" PRIdz
"\n", index);
45 ArrayList_Remove(arrayList, (
void*)(
size_t)100);
47 rc = ArrayList_IndexOf(arrayList, (
void*)(
size_t)6, -1, -1);
48 printf(
"ArrayList index: %d\n", rc);
53 for (
size_t index = 0; index < elemsToInsert; index++)
55 val = (size_t)ArrayList_GetItem(arrayList, 0);
56 if (!ArrayList_RemoveAt(arrayList, 0))
61 printf(
"ArrayList: shifted %" PRIdz
" entries, expected value %" PRIdz
", got %" PRIdz
68 rc = ArrayList_IndexOf(arrayList, (
void*)elemsToInsert, -1, -1);
69 printf(
"ArrayList index: %d\n", rc);
73 count = ArrayList_Count(arrayList);
74 printf(
"ArrayList count: %" PRIuz
"\n", count);
78 ArrayList_Clear(arrayList);
81 ArrayList_Free(arrayList);