19 #include <freerdp/utils/pod_arrays.h>
22 static BOOL cb_compute_sum(UINT32* v,
void* target)
24 UINT32* ret = (UINT32*)target;
29 static BOOL cb_stop_at_5(UINT32* v,
void* target)
31 UINT32* ret = (UINT32*)target;
36 static BOOL cb_set_to_1(UINT32* v,
void* target)
42 static BOOL cb_reset_after_1(UINT32* v,
void* target)
44 ArrayUINT32* a = (ArrayUINT32*)target;
45 array_uint32_reset(a);
55 static BOOL cb_basic_struct(BasicStruct* v,
void* target)
57 return (v->v1 == 1) && (v->v2 == 2);
60 POD_ARRAYS_IMPL(BasicStruct, basicstruct)
62 int TestPodArrays(
int argc,
char* argv[])
66 UINT32 foreach_index = 0;
67 ArrayUINT32 uint32s = { 0 };
69 const UINT32* cptr = NULL;
70 ArrayBasicStruct basicStructs = { 0 };
71 BasicStruct basicStruct = { 1, 2 };
73 array_uint32_init(&uint32s);
74 array_basicstruct_init(&basicStructs);
76 for (UINT32 i = 0; i < 10; i++)
77 if (!array_uint32_append(&uint32s, i))
81 if (!array_uint32_foreach(&uint32s, cb_compute_sum, &sum))
88 if (array_uint32_foreach(&uint32s, cb_stop_at_5, &foreach_index))
91 if (foreach_index != 5)
94 if (array_uint32_get(&uint32s, 4) != 4)
97 array_uint32_set(&uint32s, 4, 5);
98 if (array_uint32_get(&uint32s, 4) != 5)
101 ptr = array_uint32_data(&uint32s);
105 cptr = array_uint32_cdata(&uint32s);
110 if (!array_uint32_foreach(&uint32s, cb_set_to_1, NULL) || array_uint32_get(&uint32s, 5) != 1)
115 if (!array_uint32_foreach(&uint32s, cb_reset_after_1, &uint32s) || array_uint32_size(&uint32s))
119 if (!array_basicstruct_append(&basicStructs, basicStruct))
122 if (!array_basicstruct_foreach(&basicStructs, cb_basic_struct, NULL))
128 array_uint32_uninit(&uint32s);
129 array_basicstruct_uninit(&basicStructs);