69 char data[] =
"abcdefghij";
81 assert_ptr_not_equal(
it->data, NULL);
86 assert_ptr_not_equal(
array1, NULL);
116 assert_ptr_equal(
array, NULL);
131 assert_ptr_equal(
array.buffer, NULL);
132 assert_int_equal(
array.items, 0);
134 assert_int_equal(
array.items, 0);
138 assert_ptr_not_equal(
array.buffer, NULL);
139 assert_int_equal(
array.items, 10);
141 assert_int_equal(
array.items, 0);
149 assert_ptr_not_equal(
array.buffer, NULL);
150 assert_int_equal(
array.items, 10);
154 assert_int_equal(
array.items, 0);
159 assert_int_equal(
array.items, 10);
160 const char data[10] =
"1234567890";
161 for(
unsigned int index = 0; index < 10; index++) {
166 assert_int_equal(
array.items, 0);
175 assert_ptr_equal(
it, NULL);
179 assert_ptr_equal(
it, NULL);
182 assert_ptr_equal(
array, NULL);
187 for(
int i = 0; i < 10; i++) {
190 assert_ptr_equal(
it->array,
array1);
191 if((i == 0) || ((i % 3) != 0)) {
192 assert_ptr_equal(
it->data, NULL);
194 assert_ptr_equal(
it->data, &
data[i]);
202 assert_ptr_equal(
it, NULL);
209 assert_ptr_equal(
it->array,
array1);
210 assert_ptr_equal(
it->data, &
data[3]);
216 assert_ptr_not_equal(
array, NULL);
217 assert_ptr_not_equal(
array->buffer, NULL);
221 assert_ptr_equal(
it, NULL);
229 assert_ptr_equal(
it, NULL);
236 assert_ptr_equal(
it->array,
array1);
237 assert_ptr_equal(
it->data, NULL);
243 assert_ptr_equal(
it, NULL);
250 assert_ptr_equal(
it->array,
array1);
251 assert_ptr_equal(
it->data, &
data[9]);
257 assert_ptr_not_equal(
array, NULL);
258 assert_ptr_not_equal(
array->buffer, NULL);
262 assert_ptr_equal(
it, NULL);
270 assert_ptr_equal(
it, NULL);
276 assert_ptr_not_equal(
it, NULL);
278 assert_ptr_equal(
it->array,
array1);
279 assert_ptr_equal(
it->data, NULL);
283 for(
int i = 0; i < 10; i++) {
288 assert_ptr_equal(
it, NULL);
292 for(
int i = 0; i < 10; i++) {
297 assert_ptr_equal(
it, NULL);
303 assert_ptr_equal(
it, NULL);
312 assert_ptr_equal(
it->array,
array1);
313 assert_ptr_equal(
it->data, &
data[6]);
317 assert_ptr_equal(
it->array,
array1);
318 assert_ptr_equal(
it->data, &
data[9]);
321 assert_ptr_equal(
it, NULL);
327 assert_ptr_equal(
it, NULL);
336 assert_ptr_equal(
it->array,
array1);
337 assert_ptr_equal(
it->data, NULL);
341 assert_ptr_equal(
it->array,
array1);
342 assert_ptr_equal(
it->data, NULL);
346 assert_ptr_equal(
it->array,
array1);
347 assert_ptr_equal(
it->data, NULL);
351 assert_ptr_equal(
it->array,
array1);
352 assert_ptr_equal(
it->data, NULL);
355 assert_ptr_equal(
it, NULL);
361 assert_ptr_equal(
it, NULL);
372 assert_ptr_equal(
it->array,
array1);
373 assert_ptr_equal(
it->data, &
data[6]);
377 assert_ptr_equal(
it->array,
array1);
378 assert_ptr_equal(
it->data, &
data[3]);
382 assert_ptr_equal(
it->array,
array1);
383 assert_ptr_equal(
it->data, &
data[1]);
386 assert_ptr_equal(
it, NULL);
394 assert_ptr_equal(
it, NULL);
403 assert_ptr_equal(
it->array,
array1);
404 assert_ptr_equal(
it->data, NULL);
408 assert_ptr_equal(
it->array,
array1);
409 assert_ptr_equal(
it->data, NULL);
413 assert_ptr_equal(
it->array,
array1);
414 assert_ptr_equal(
it->data, NULL);
418 assert_ptr_equal(
it->array,
array1);
419 assert_ptr_equal(
it->data, NULL);
423 assert_ptr_equal(
it->array,
array1);
424 assert_ptr_equal(
it->data, NULL);
428 assert_ptr_equal(
it->array,
array1);
429 assert_ptr_equal(
it->data, NULL);
433 assert_ptr_equal(
it->array,
array1);
434 assert_ptr_equal(
it->data, NULL);
437 assert_ptr_equal(
it, NULL);
728 assert_ptr_equal(
it, NULL);
734 assert_ptr_not_equal(
it, NULL);
740 assert_ptr_not_equal(
it, NULL);
749 assert_ptr_not_equal(
it, NULL);
756 assert_ptr_not_equal(
it, NULL);
771 assert_ptr_equal(
it, NULL);
777 assert_ptr_not_equal(
it, NULL);
783 assert_ptr_not_equal(
it, NULL);
792 assert_ptr_not_equal(
it, NULL);
799 assert_ptr_not_equal(
it, NULL);
814 assert_ptr_equal(d, &
data[3]);
820 assert_ptr_equal(d, &
data[6]);
826 assert_ptr_equal(d, &
data[9]);
840 assert_ptr_equal(d, &
data[9]);
846 assert_ptr_equal(d, &
data[6]);
852 assert_ptr_equal(d, &
data[3]);
906 }
else if(d1[0] > d2[0]) {
915 const char data[16] =
"KRATELEPUIMQCXOS";
916 const char sorted[16] =
"ACEEIKLMOPQRSTUX";
918 const char data_sets[6][3] = {
919 "ABC",
"BCA",
"CAB",
"CBA",
"BAC",
"ACB"
924 for(
unsigned int index = 0; index < 16; index++) {
929 for(
unsigned int index = 0; index < 16; index++) {
931 printf(
"%c\n", d[0]);
932 assert_int_equal(d[0], sorted[index]);
937 for(
unsigned int index = 0; index < 32; index += 2) {
942 for(
unsigned int index = 0; index < 16; index++) {
944 printf(
"%c\n", d[0]);
945 assert_int_equal(d[0], sorted[index]);
950 for(
int sets = 0; sets < 6; sets++) {
951 printf(
"\n %d - ", sets);
953 for(
unsigned int index = 0; index < 3; index++) {
958 for(
unsigned int index = 0; index < 3; index++) {
Ambiorix array API header file.
amxc_array_it_t * amxc_array_it_get_next_free(const amxc_array_it_t *const reference)
Gets the next free item in the array, starting from the provided array iterator.
int amxc_array_it_set_data(amxc_array_it_t *const it, void *data)
Sets the data pointer of an array iterator.
amxc_array_it_t * amxc_array_it_get_previous(const amxc_array_it_t *const reference)
Gets the previous used item in the array, starting from the provided array iterator.
amxc_array_it_t * amxc_array_it_get_next(const amxc_array_it_t *const reference)
Gets the next used item in the array, starting from the provided array iterator.
void * amxc_array_it_take_data(amxc_array_it_t *const it)
Gets and removes a data pointer from the iterator.
amxc_array_it_t * amxc_array_it_get_previous_free(const amxc_array_it_t *const reference)
Gets the previous free item in the array, starting from the provided array iterator.
AMXC_INLINE void * amxc_array_it_get_data(const amxc_array_it_t *const it)
Gets the data pointer of array iterator.
unsigned int amxc_array_it_index(const amxc_array_it_t *const it)
Gets the index of the iterator in the array.
amxc_array_it_t * amxc_array_get_last(const amxc_array_t *const array)
Gets the item iterator of the last used item in the array.
AMXC_INLINE size_t amxc_array_capacity(const amxc_array_t *const array)
Gets the capacity of the array.
int amxc_array_shift_right(amxc_array_t *const array, const size_t items, amxc_array_it_delete_t func)
Shift all items to the right in the array.
amxc_array_it_t * amxc_array_set_data_at(amxc_array_t *const array, const unsigned int index, void *data)
Sets data at the given index.
void * amxc_array_take_first_data(amxc_array_t *const array)
Takes the data pointer from the first used item in the array.
size_t amxc_array_size(const amxc_array_t *const array)
Calculates the number of used items in the array.
amxc_array_it_t * amxc_array_get_last_free(const amxc_array_t *const array)
Gets the last free position in the array.
int amxc_array_shift_left(amxc_array_t *const array, const size_t items, amxc_array_it_delete_t func)
Shift all items to the left in the array.
void * amxc_array_take_last_data(amxc_array_t *const array)
Takes the data pointer from the last used item in the array.
int amxc_array_init(amxc_array_t *const array, const size_t items)
Initializes an array.
amxc_array_it_t * amxc_array_get_at(const amxc_array_t *const array, const unsigned int index)
Gets the item iterator for the given index.
int amxc_array_shrink(amxc_array_t *const array, const size_t items, amxc_array_it_delete_t func)
Shrinks the array.
amxc_array_it_t * amxc_array_get_first(const amxc_array_t *const array)
Gets the item iterator of the first used item in the array.
amxc_array_it_t * amxc_array_prepend_data(amxc_array_t *const array, void *data)
Adds an item before the first used item in the array.
bool amxc_array_is_empty(const amxc_array_t *const array)
Checks that the array is empty.
int8_t amxc_array_new(amxc_array_t **array, const size_t items)
Allocates an array.
void amxc_array_clean(amxc_array_t *const array, amxc_array_it_delete_t func)
Removes all items from the array.
amxc_array_it_t * amxc_array_get_first_free(const amxc_array_t *const array)
Gets the first free position in the array.
amxc_array_it_t * amxc_array_append_data(amxc_array_t *const array, void *data)
Adds an item after the last used item in the array.
int amxc_array_sort(amxc_array_t *const array, amxc_array_it_cmp_t cmp)
Sorts the content of the array.
int amxc_array_grow(amxc_array_t *const array, const size_t items)
Expands the array.
void amxc_array_delete(amxc_array_t **array, const amxc_array_it_delete_t func)
Frees the previously allocated array.
The array iterator structure.
struct _amxc_array_it * buffer
void test_amxc_array_is_empty(UNUSED void **state)
void test_amxc_array_is_empty_null(UNUSED void **state)
void test_amxc_array_it_get_data_null(UNUSED void **state)
void test_amxc_array_take_last_data_null(UNUSED void **state)
void test_amxc_array_it_get_next_free(UNUSED void **state)
void test_amxc_array_get_at(UNUSED void **state)
void test_amxc_array_capacity(UNUSED void **state)
void test_amxc_array_it_take_data(UNUSED void **state)
static int test_cmp(amxc_array_it_t *it1, amxc_array_it_t *it2)
void test_amxc_array_set_at(UNUSED void **state)
void test_amxc_array_get_last_free_null(UNUSED void **state)
void test_amxc_array_it_get_previous(UNUSED void **state)
void test_amxc_array_prepend_data_null(UNUSED void **state)
void test_amxc_array_get_first_free_full(UNUSED void **state)
void test_amxc_array_get_first_free(UNUSED void **state)
void test_amxc_array_get_at_null(UNUSED void **state)
void test_amxc_array_prepend_data(UNUSED void **state)
void test_amxc_array_get_last_free(UNUSED void **state)
void test_amxc_array_get_last_free_full(UNUSED void **state)
void test_amxc_array_get_first_null(UNUSED void **state)
void test_amxc_array_append_data_null(UNUSED void **state)
void test_amxc_array_get_first_empty(UNUSED void **state)
void test_amxc_array_it_set_data_null(UNUSED void **state)
int test_amxc_array_setup(UNUSED void **state)
void test_amxc_array_size(UNUSED void **state)
void test_amxc_array_shift_left_all(UNUSED void **state)
void test_amxc_array_get_last_empty(UNUSED void **state)
void test_amxc_array_it_get_previous_null(UNUSED void **state)
void test_amxc_array_it_get_next_null(UNUSED void **state)
void test_amxc_array_it_get_data(UNUSED void **state)
void test_amxc_array_grow_null(UNUSED void **state)
void test_amxc_array_shift_null(UNUSED void **state)
void test_amxc_array_init_clean(UNUSED void **state)
void test_amxc_array_it_get_next(UNUSED void **state)
static amxc_array_t * array1
int test_amxc_array_teardown(UNUSED void **state)
void test_amxc_array_it_take_data_null(UNUSED void **state)
void test_amxc_array_get_first(UNUSED void **state)
void test_amxc_array_get_last_null(UNUSED void **state)
void test_amxc_array_clean_cb(UNUSED void **state)
void test_amxc_array_sort(UNUSED void **state)
void test_amxc_array_grow(UNUSED void **state)
void test_amxc_array_it_get_previous_free_null(UNUSED void **state)
void test_amxc_array_set_at_null(UNUSED void **state)
void test_amxc_array_take_first_data_null(UNUSED void **state)
void test_amxc_array_capacity_null(UNUSED void **state)
void test_amxc_array_shift_left(UNUSED void **state)
void test_amxc_array_size_null(UNUSED void **state)
void test_amxc_array_it_index_null(UNUSED void **state)
void test_amxc_array_get_first_free_null(UNUSED void **state)
void test_amxc_array_it_index(UNUSED void **state)
static void amxc_check_array_it_delete(amxc_array_it_t *it)
void test_amxc_array_append_data(UNUSED void **state)
void test_amxc_array_it_get_previous_free(UNUSED void **state)
void test_amxc_array_shrink(UNUSED void **state)
void test_amxc_array_it_set_data(UNUSED void **state)
void test_amxc_array_new_delete_null(UNUSED void **state)
void test_amxc_array_shift_right_all(UNUSED void **state)
void test_amxc_array_init_clean_null(UNUSED void **state)
void test_amxc_array_take_first_data(UNUSED void **state)
void test_amxc_array_get_last(UNUSED void **state)
void test_amxc_array_take_last_data(UNUSED void **state)
static void amxc_reset_test_array()
void test_amxc_array_shrink_null(UNUSED void **state)
void test_amxc_array_shift_right(UNUSED void **state)
void test_amxc_array_it_get_next_free_null(UNUSED void **state)
static unsigned int array[2006]
static amxc_htable_it_t it[2000]
static amxc_llist_it_t it2
static amxc_llist_it_t it1