@@ -88,8 +88,6 @@ struct list *list_get(struct list *l, size_t index){
|
|||||||
ind ++;
|
ind ++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(ind >= index) return NULL;
|
|
||||||
|
|
||||||
return tmp;
|
return tmp;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-3
@@ -24,7 +24,7 @@ Test(basics_suite, test_append) {
|
|||||||
Test(basics_suite, test_count) {
|
Test(basics_suite, test_count) {
|
||||||
struct list *l = NULL;
|
struct list *l = NULL;
|
||||||
|
|
||||||
cr_assert_eq(list_count(l), 0, "Une liste vide doit avoir une taille de 0.");
|
cr_assert_eq(list_count(l), 0, "doit renvoyer 0, c'est un liste vide");
|
||||||
|
|
||||||
l = list_append(l, 10);
|
l = list_append(l, 10);
|
||||||
l = list_append(l, 20);
|
l = list_append(l, 20);
|
||||||
@@ -129,9 +129,9 @@ Test(basics_suite, test_list_remove){
|
|||||||
l = list_append(l, 7);
|
l = list_append(l, 7);
|
||||||
l = list_append(l, 3);
|
l = list_append(l, 3);
|
||||||
l = list_append(l, 7);
|
l = list_append(l, 7);
|
||||||
l = list_append(l, 1); // [1] -> [7] -> [3] -> [1]
|
l = list_append(l, 1); // [1] -> [7] -> [3] -> [7]
|
||||||
|
|
||||||
int rm = list_remove(&l, 7); // Retire le premier 7. l devient [1] -> [7] -> [3]
|
int rm = list_remove(&l, 7); // Retire le premier 7. l devient [1] -> [3] -> [7]
|
||||||
cr_assert_eq(rm, 1, "Le noeud 7 doit etre supprimé");
|
cr_assert_eq(rm, 1, "Le noeud 7 doit etre supprimé");
|
||||||
|
|
||||||
struct list *tmp = list_get(l, 0);
|
struct list *tmp = list_get(l, 0);
|
||||||
|
|||||||
Reference in New Issue
Block a user