#include #include #include "../Chains_across_the_Island/Fundamentals/basics/basics.h" // Test pour list_append Test(basics_suite, test_append) { struct list *l = NULL; l = list_append(l, 42); cr_assert_not_null(l, "La liste ne doit pas être NULL après le premier ajout."); cr_assert_eq(l->data, 42, "La donnée du premier nœud doit être 42."); l = list_append(l, 7); cr_assert_not_null(l->next, "Le deuxième nœud doit exister."); cr_assert_eq(l->next->data, 7, "La donnée du deuxième nœud doit être 7."); list_destroy(l); } // Test pour list_count Test(basics_suite, test_count) { struct list *l = NULL; cr_assert_eq(list_count(l), 0, "Une liste vide doit avoir une taille de 0."); l = list_append(l, 10); l = list_append(l, 20); l = list_append(l, 30); printf("%i\n", list_count(l)); cr_assert_eq(list_count(l), 3, "La liste doit contenir 3 éléments."); // printf("%i\n", list_count(l)); list_destroy(l); } // Test pour list_insert Test(basics_suite, test_insert) { struct list *l = NULL; // Insertion dans une liste vide int res1 = list_insert(&l, 0, 100); cr_assert_eq(res1, 0, "L'insertion à l'index 0 doit réussir."); cr_assert_eq(l->data, 100, "La valeur insérée doit être 100."); // Insertion hors limite int res2 = list_insert(&l, 5, 200); cr_assert_eq(res2, 1, "L'insertion hors limite doit échouer et renvoyer 1."); list_destroy(l); }