add: ft_list_push_front
This commit is contained in:
32
test/test.c
32
test/test.c
@ -103,6 +103,7 @@ t_list *create_list(size_t len)
|
||||
for (size_t i = 0; i < len; i++)
|
||||
{
|
||||
current->next = malloc(sizeof(t_list));
|
||||
current->data = (void *) i;
|
||||
if (current->next == NULL)
|
||||
{
|
||||
destroy_list(current, NULL);
|
||||
@ -120,7 +121,7 @@ t_list *create_list(size_t len)
|
||||
void multiple_test_list_size()
|
||||
{
|
||||
size_t len;
|
||||
t_list **root;
|
||||
t_list *root;
|
||||
size_t specific_size[nb_specific_test] = {0};
|
||||
|
||||
srand(time(NULL));
|
||||
@ -137,6 +138,31 @@ void multiple_test_list_size()
|
||||
}
|
||||
}
|
||||
|
||||
void multiple_test_push_front()
|
||||
{
|
||||
size_t len;
|
||||
t_list *root;
|
||||
|
||||
srand(time(NULL));
|
||||
|
||||
for (size_t i = 0; i < nb_random_test; i++)
|
||||
{
|
||||
len = rand() % 100;
|
||||
|
||||
root = create_list(len);
|
||||
if (root == NULL)
|
||||
return;
|
||||
ft_list_push_front(&root, (void *) 101);
|
||||
printf("data: ");
|
||||
test_size_t((size_t) root->data, 101);
|
||||
printf(" data-next: ");
|
||||
test_size_t((size_t) root->next->data, 0);
|
||||
printf(" list-size: ");
|
||||
test_int(len + 1, ft_list_size(root));
|
||||
printf("\n");
|
||||
}
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
printf("STRLEN\n");
|
||||
@ -165,4 +191,8 @@ int main()
|
||||
printf("FT_LIST_SIZE\n");
|
||||
multiple_test_list_size();
|
||||
printf("\n");
|
||||
|
||||
printf("FT_LIST_PUSH_FRONT\n");
|
||||
multiple_test_push_front();
|
||||
printf("\n");
|
||||
}
|
Reference in New Issue
Block a user