I have a void insert function and I want to test if it inserts correctly. I'm using CMocka framework for testing.
I've tried to do dpl_insert(ret, "mock_value")
instead of the will_return()
but it seems that no value is appended to the list.
t_list **dpl_create();
int ft_list_size(t_list *self);
void __wrap_dpl_insert(t_list **self, void *data)
{
check_expected(self);
check_expected(data);
}
static void test_dpl_insert_empty_list(void **state)
{
(void) state;
t_list **ret = dpl_create(); //Initialization of an empty struct.
int ret_size;
expect_value(__wrap_dpl_insert, self, ret);
expect_value(__wrap_dpl_insert, data, "mock_value");
will_return(__wrap_dpl_insert, XXX); //PROBLEM RESIDES HERE.
ret_size = ft_list_size(*ret);
fprintf(stderr, "Size of the list=>%d\n", ret_size);
}
With dpl_insert(ret, "mock_value")
the fprintf()
prints 0, like if no element was added.
My objective is to obtain 1 from fprintf()
.
Aucun commentaire:
Enregistrer un commentaire