41 Commits

Author SHA1 Message Date
lucas 6adb153201 go se coucher
Tests TP prog-104-p-02-2030 / test (push) Failing after 10s
2026-04-06 03:04:40 +02:00
lucas 30efd857c1 test double.c
Tests TP prog-104-p-02-2030 / test (push) Failing after 30s
2026-04-03 17:20:49 +02:00
lucas a92c8a4ddf correction double.c
Tests TP prog-104-p-02-2030 / test (push) Failing after 9s
2026-04-03 17:07:41 +02:00
lucas 3c46959903 correction
Tests TP prog-104-p-02-2030 / test (push) Failing after 32s
2026-04-03 17:05:17 +02:00
lucas 7ae0683809 tentative correction double.c insert 2026-04-03 16:59:10 +02:00
lucas 40d224a8f8 changment dans basic.c et dans double.c
Tests TP prog-104-p-02-2030 / test (push) Failing after 8s
2026-04-03 16:54:34 +02:00
lucas 72a13f7a19 correction append
Tests TP prog-104-p-02-2030 / test (push) Failing after 28s
2026-04-03 16:45:12 +02:00
lucas 95129eb608 tt
Tests TP prog-104-p-02-2030 / test (push) Failing after 8s
2026-04-03 16:34:35 +02:00
lucas bcdfc07ee7 tt
Tests TP prog-104-p-02-2030 / test (push) Failing after 7s
2026-04-03 16:31:26 +02:00
lucas 44746d970c correction yaml
Tests TP prog-104-p-02-2030 / test (push) Successful in 29s
2026-04-03 02:11:32 +02:00
lucas 8a194966d7 push double
Tests TP prog-104-p-02-2030 / test (push) Successful in 20s
2026-04-03 02:09:12 +02:00
lucas 130ff44e16 er
Tests Basics avec Criterion / test (push) Successful in 7s
2026-04-02 23:30:04 +02:00
lucas 7d5bb35f0b te
Tests Basics avec Criterion / test (push) Failing after 8s
2026-04-02 23:18:02 +02:00
lucas d10807edb7 c
Tests Basics avec Criterion / test (push) Failing after 7s
2026-04-02 22:28:50 +02:00
lucas a3142bf861 test nouvelle version workflow
Tests Basics avec Criterion / test (push) Failing after 6s
2026-04-02 22:26:39 +02:00
lucas 97fa4e5c8b test append
Tests Basics avec Criterion / test (push) Failing after 6s
2026-04-02 22:17:51 +02:00
lucas 8491a3aa7d test
Tests Basics avec Criterion / test (push) Failing after 6s
2026-04-02 22:13:01 +02:00
lucas 6da27cbf48 test
Tests Basics avec Criterion / test (push) Failing after 5s
2026-04-02 22:11:20 +02:00
lucas 4a720a3569 test
Tests Basics avec Criterion / test (push) Failing after 6s
2026-04-02 19:58:47 +02:00
lucas d0c7a97131 test gitea
Tests Basics avec Criterion / test (push) Successful in 5s
2026-04-02 19:57:05 +02:00
lucas 2440002e28 chg nom 2026-04-02 19:40:41 +02:00
lucas 3d0dd9e993 retout 2026-04-02 19:00:43 +02:00
lucas 3ffa5c3bad test 2026-04-02 16:56:26 +02:00
lucas 472e8cc8ec tests 2026-04-02 16:54:02 +02:00
lucas a87b015d99 push ecole 2026-04-02 16:06:31 +02:00
lucas 6d932bfe28 correction
Tests Basics avec Criterion / test (push) Failing after 6s
2026-04-02 15:56:59 +02:00
lucas 3e87619a34 correction
Tests Basics avec Criterion / test (push) Failing after 6s
2026-04-02 15:53:37 +02:00
lucas f5c181b822 correction
Tests Basics avec Criterion / test (push) Successful in 5s
2026-04-02 15:52:42 +02:00
lucas 7b93a83737 test
Tests Basics avec Criterion / test (push) Failing after 6s
2026-04-02 14:56:28 +02:00
lucas e56b334e85 test
Tests Basics avec Criterion / test (push) Failing after 6s
2026-04-02 14:55:12 +02:00
lucas 5a3d3d1083 correction nom image docker
Tests Basics avec Criterion / test (push) Failing after 10s
2026-04-02 14:50:28 +02:00
lucas 5829325c56 test nouvelle image
Tests Basics avec Criterion / test (push) Failing after 0s
2026-04-02 14:49:07 +02:00
lucas cd32edb6fe test n8
Tests Basics avec Criterion / test (push) Failing after 9s
2026-04-02 02:18:52 +02:00
lucas b6ad1eaafc test n7
Tests Basics avec Criterion / test (push) Successful in 10s
2026-04-02 02:14:28 +02:00
lucas f135bcacf9 test n6
Tests Basics avec Criterion / test (push) Failing after 8s
2026-04-02 02:13:03 +02:00
lucas c55ab6ab36 test n5
Tests Basics avec Criterion / test (push) Failing after 8s
2026-04-02 02:11:26 +02:00
lucas 41c175cac4 test n4
Tests Basics avec Criterion / test (push) Failing after 4s
2026-04-02 02:08:16 +02:00
lucas ccf8075da7 test n3
Tests Basics avec Criterion / test (push) Failing after 4s
2026-04-02 02:06:52 +02:00
lucas db23925de1 test n2
Tests Basics avec Criterion / test (push) Failing after 7s
2026-04-02 02:04:50 +02:00
lucas a731d3ebc4 push de test
Tests C avec Criterion / test (push) Failing after 17s
2026-04-02 02:01:17 +02:00
lucas a62ec41abd ajout 2026-04-02 00:31:53 +02:00
6 changed files with 710 additions and 37 deletions
+71
View File
@@ -0,0 +1,71 @@
name: Tests TP prog-104-p-02-2030
on: [push]
jobs:
test:
runs-on: ubuntu-latest
container:
image: git.blackbucket.fr/lucas/epita_tp_c:latest
steps:
- name: preparation env
run: pacman -Syu --noconfirm nodejs git gcc criterion
- name: checkout
uses: actions/checkout@v4
- name: Compilation
run: >
gcc -Wall -Wextra
-I./Chains_across_the_Island/Fundamentals/basics
-o test
Chains_across_the_Island/Fundamentals/basics/basics.c
tests/tests.c
Chains_across_the_Island/Fundamentals/double/double.c
-lcriterion -fsanitize=address -g
- name: Test - basics list_append
if: success() || failure()
run: ./test --filter "basics_suite/test_append"
- name: Test - basics list_count
if: success() || failure()
run: ./test --filter "basics_suite/test_count"
- name: Test - basics list_insert
if: success() || failure()
run: ./test --filter "basics_suite/test_insert"
- name: Test - basics list_get
if: success() || failure()
run: ./test --filter "basics_suite/test_get"
- name: Test - basics list_find
if: success() || failure()
run: ./test --filter "basics_suite/test_find"
- name: Test - basics list_delete_at
if: success() || failure()
run: ./test --filter "basics_suite/test_delete_at"
- name: Test - basics list_remove
if: success() || failure()
run: ./test --filter "basics_suite/test_list_remove"
- name: Test - double dlist_append
if: success() || failure()
run: ./test --filter "double_suite/test_append"
- name: Test - double dlist_insert
if: success() || failure()
run: ./test --filter "double_suite/test_insert"
- name: Test - double dlist_delete_at
if: success() || failure()
run: ./test --filter "double_suite/test_delete_at"
- name: Test - double dlist_remove
if: success() || failure()
run: ./test --filter "double_suite/test_remove"
@@ -1,46 +1,203 @@
#include "basics.h"
#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>
struct list *list_append(struct list *l, int e)
{
//FIXME
struct list *new_node = malloc(sizeof(struct list));
if(!new_node) return NULL;
new_node->data = e;
new_node->next = l;
return new_node;
/*
struct list *tmp = l;
struct list *new_node = calloc(1, sizeof(struct list));
if (!new_node) return NULL;
new_node->data = e;
if(!l) return new_node;
while (tmp->next != NULL) tmp = tmp->next;
tmp->next = new_node;
return l;
*/
}
size_t list_count(struct list *l){
int nbr_nodes = 0;
//if (!l) return nbr_nodes;
struct list *tmp = l;
//nbr_nodes ++;
while(tmp != NULL) {
nbr_nodes ++;
tmp = tmp->next;
}
return nbr_nodes;
}
size_t list_count(struct list *l)
int list_insert(struct list **l, size_t index, int e){
if(!l) return 1;
struct list *new_node = malloc(sizeof(struct list));
if(!new_node) return 1;
if(index == 0){
*l = list_append(*l, e);
/*
new_node->data = e;
new_node->next = *l;
*l = new_node;
*/
return 0;
}
struct list *tmp = *l;
size_t ind = 0;
while(tmp != NULL && ind <index - 1){
tmp = tmp->next;
ind ++;
}
if (!tmp) return 1;
new_node->data = e;
new_node->next = tmp->next;
tmp->next = new_node;
return 0;
}
struct list *list_get(struct list *l, size_t index){
struct list *tmp = l;
size_t ind = 0;
while(tmp != NULL && ind < index){
tmp = tmp->next;
ind ++;
}
return tmp;
}
void list_destroy(struct list *l){
if (!l) return;
list_destroy(l->next);
free(l);
}
struct list *list_find(struct list *l, int e){
struct list *tmp = l;
while (tmp != NULL && tmp->data != e) tmp = tmp->next;
return tmp;
}
struct list *list_delete_at(struct list **l, size_t index){
if (!l || !*l) return NULL;
struct list *old = *l;
if ( index == 0){
*l = old->next;
return old;
}
struct list *tmp = *l;
size_t ind = 0;
while(tmp != NULL && ind < index - 1){
tmp = tmp->next;
ind ++;
}
if (ind == index - 1) {
old = tmp->next;
tmp->next = old->next;
return old;
}
return NULL;
}
int list_remove(struct list **l, int e){
struct list *old = NULL;
struct list *tmp = *l;
while (tmp != NULL && tmp->data != e){
old = tmp;
tmp = tmp->next;
}
if (!tmp) return 0;
if(!old) *l = tmp->next;
else old->next = tmp->next;
free(tmp);
return 1;
}
void list_print(struct list *l){
struct list *tmp = l;
while (tmp != NULL){
printf("%i",tmp->data);
if (tmp->next != NULL) printf(" -> ");
tmp = tmp->next;
}
printf("\n");
}
/*
int main(void)
{
//FIXME
}
struct list *l = NULL;
int list_insert(struct list **l, size_t index, int e)
{
}
l = list_append(l, 3);
l = list_append(l, 2);
l = list_append(l, 1);
struct list *list_get(struct list *l, size_t index)
{
// l = [1] -> [2] -> [3]
list_insert(&l, 1, 99); // l = [1] -> [99] -> [2] -> [3], and list_insert returns 0
list_insert(&l, 9, 99); // list unchanged, returns 1
//FIXME
}
list_print(l);
struct list *list_find(struct list *l, int e)
{
//FIXME
}
list_destroy(l);
struct list *list_delete_at(struct list **l, size_t index)
{
//FIXME
}
int list_remove(struct list **l, int e)
{
//FIXME
}
void list_destroy(struct list *l)
{
//FIXME
}
void list_print(struct list *l)
{
//FIXME
return 0;
}
*/
Binary file not shown.
@@ -1,26 +1,140 @@
#include "double.h"
#include <stddef.h>
#include <stdlib.h>
#include <stdio.h>
struct dlist *dlist_append(struct dlist *l, int e)
{
//FIXME
struct dlist *new_node = calloc(1, sizeof(struct dlist));
if(!new_node) return NULL;
new_node->prev = NULL;
new_node->next = l;
new_node->data = e;
if (l) l->prev = new_node;
return new_node;
}
int dlist_insert(struct dlist **l, size_t index, int e)
{
//FIXME
if(!l) return 1;
//struct dlist *new_node = malloc(sizeof(struct dlist));
//if(!new_node) return 1;
//struct dlist *tmp = *l;
if(index == 0){
*l = dlist_append(*l, e);
if(!l) return 1;
return 0;
}
struct dlist *tmp = *l;
size_t ind = 0;
while(tmp != NULL && ind < index - 1){
tmp = tmp->next;
ind ++;
}
if(!tmp) return 1;
struct dlist *new_node = malloc(sizeof(struct dlist));
if(!new_node) return 1;
new_node->data = e;
new_node->next = tmp->next;
new_node->prev = tmp;
if (tmp->next != NULL) tmp->next->prev = new_node;
tmp->next = new_node;
return 0;
}
struct dlist *dlist_delete_at(struct dlist **l, size_t index)
{
//FIXME
if(!l || *l) return NULL;
struct dlist *old = NULL;
if(index == 0){
old = *l;
*l = old->next;
return old;
}
struct dlist *tmp = *l;
size_t ind = 0;
while(tmp != NULL && ind < index -1){
tmp = tmp->next;
ind ++;
}
if(ind == index -1){
old = tmp->next;
tmp->prev = old->prev;
tmp->next = old->next;
return old;
}
return NULL;
}
int dlist_remove(struct dlist **l, int e)
{
//FIXME
struct dlist *old = NULL;
struct dlist *tmp = *l;
while(tmp != NULL && tmp->data != e){
old = tmp;
tmp = tmp->next;
}
if(!tmp) return 0;
if(!old){
*l = tmp->next;
}
else {
old->next = tmp->next;
old->prev = tmp->prev;
}
free(tmp);
return 1;
}
void dlist_print(struct dlist *l)
{
//FIXME
struct dlist *tmp = l;
while (tmp != NULL){
printf("%i", tmp->data);
if (tmp->next != NULL) printf(" <-> ");
tmp = tmp->next;
}
printf("\n");
}
@@ -1,11 +1,47 @@
#include "practice.h"
#include "../../utils/lists.h"
#include "../basics/basics.h"
int is_palindrome(struct dlist *l)
{
//FIXME
if (!l || l->next != NULL) return 1;
struct dlist *tmp = l;
int indexb = 0;
while (tmp->next != NULL) {
indexb ++;
tmp = tmp->next;
}
struct dlist *back = tmp;
tmp = l;
int indexp = 0;
while (indexp < indexb){
if (tmp->data != back->data) return 0;
indexp ++;
indexb --;
tmp = tmp->next;
back = back->prev;
}
return 1;
}
struct list *reverse(struct list *l)
{
//FIXME
struct list *tmp =l;
struct list *rslt = NULL;
while(l != NULL){
rslt = list_append(rslt, l->data);
l = l->next;
}
return rslt;
}
+295
View File
@@ -0,0 +1,295 @@
#include <criterion/criterion.h>
#include <criterion/internal/assert.h>
#include <stddef.h>
#include <stdlib.h>
#include "../Chains_across_the_Island/Fundamentals/basics/basics.h"
#include "../Chains_across_the_Island/Fundamentals/double/double.h"
#include <stdio.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 peux pas etre null apres un ajout");
cr_assert_eq(l->data, 42, "la data du 1er noeud doit être 42");
l = list_append(l, 7);
cr_assert_not_null(l->next, "le deuxieme noeud doit exister");
cr_assert_eq(l->data, 7, "Le premier noeud doit etre 7");
cr_assert_eq(l->next->data, 42, "Le second noeud doit etre 42");
list_destroy(l);
}
// Test pour list_count
Test(basics_suite, test_count) {
struct list *l = NULL;
cr_assert_eq(list_count(l), 0, "doit renvoyer 0, c'est un liste vide");
l = list_append(l, 10);
l = list_append(l, 20);
l = list_append(l, 30);
cr_assert_eq(list_count(l), 3, "La liste doit contenir 3 éléments.");
list_destroy(l);
}
// Test pour list_insert
Test(basics_suite, test_insert) {
struct list *l = NULL;
int res1 = list_insert(&l, 0, 100);
cr_assert_eq(res1, 0, "L'insertion à l'index 0 doit réussir.");
cr_assert_not_null(l, "La liste ne doit pas être NULL.");
cr_assert_eq(l->data, 100, "La valeur insérée doit être 100.");
int res2 = list_insert(&l, 5, 200);
cr_assert_eq(res2, 1, "Out of Range !");
list_destroy(l);
}
//Test pour list_get
Test(basics_suite, test_get){
struct list *l = NULL;
l = list_append(l, 30);
l = list_append(l, 20);
l = list_append(l, 10);
struct list *rslt = list_get(l, 0);
cr_assert_not_null(rslt, "Le pointeur ne doit pas être NULL pour l'index 0");
cr_assert_eq(rslt->data, 10, "pointer to node with data=10");
rslt = list_get(l, 2);
cr_assert_not_null(rslt, "Le pointeur ne doit pas être NULL pour l'index 2");
cr_assert_eq(rslt->data, 30, "pointer to node with data=30");
rslt = list_get(l, 5);
cr_assert_null(rslt, "Le pointeur doit etre null");
list_destroy(l);
}
//Test list_find
Test(basics_suite, test_find){
struct list *l = NULL;
l = list_append(l, 3);
l = list_append(l, 7);
l = list_append(l, 1);
struct list *rslt = list_find(l, 7);
cr_assert_not_null(rslt, "Le noeud doit être trouvé");
cr_assert_eq(rslt->data, 7, "pointer to node with data=7");
rslt = list_find(l, 42);
cr_assert_null(rslt, "pointeur doit etre null");
list_destroy(l);
}
//Test list_delete_at
Test(basics_suite, test_delete_at){
struct list *l = NULL;
l = list_append(l, 30);
l = list_append(l, 20);
l = list_append(l, 10); // [10] -> [20] -> [30]
struct list *rslt = NULL;
rslt = list_delete_at(&l, 1); // Retire le 20. l devient [10] -> [30]
cr_assert_not_null(rslt, "Le noeud retiré ne doit pas être NULL");
cr_assert_eq(rslt->data, 20, "La data du noeud supprimé doit etre de 20");
size_t count = list_count(l);
cr_assert_eq(count, 2, "La taille de la liste doit etre de 2");
struct list *tmp = list_get(l, 0);
cr_assert_not_null(tmp, "Le noeud 0 ne doit pas être NULL");
cr_assert_eq(tmp->data, 10, "La data du noeud 1 doit etre de 10");
tmp = list_get(l, 1);
cr_assert_not_null(tmp, "Le noeud 1 ne doit pas être NULL");
cr_assert_eq(tmp->data, 30, "La data du noeud 2 doit etre de 30");
tmp = list_get(l, 3);
cr_assert_null(tmp, "Le pointeur doit etre null");
list_destroy(l);
free(rslt); // rslt est totalement détaché de l, on le libère avec un simple free()
}
//Test list_remove
Test(basics_suite, test_list_remove){
struct list *l = NULL;
l = list_append(l, 7);
l = list_append(l, 3);
l = list_append(l, 7);
l = list_append(l, 1); // [1] -> [7] -> [3] -> [7]
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é");
struct list *tmp = list_get(l, 0);
cr_assert_not_null(tmp, "Le noeud 0 existe");
cr_assert_eq(tmp->data, 1, "Le noeud 1 a changé et devient 1 !");
tmp = list_get(l, 1);
cr_assert_not_null(tmp, "Le noeud 1 existe");
cr_assert_eq(tmp->data, 3, "Le noeud 2 doit etre egal a 3");
tmp = list_get(l, 2);
cr_assert_not_null(tmp, "Le noeud 2 existe");
cr_assert_eq(tmp->data,7, "Le 3 eme noeud doit etre de 7");
rm = list_remove(&l, 42);
cr_assert_eq(rm, 0, "Doit renvoyer 0 car 42 n'existe pas !");
list_destroy(l);
}
// TEST POUR double
void dlist_destroy(struct dlist *l){
struct dlist *tmp = l;
struct dlist *nex = NULL;
while(tmp != NULL) {
nex = tmp->next;
free(tmp);
tmp = nex;
}
}
int dlist_count(struct dlist *l){
struct dlist *tmp = l;
int ind = 0;
while(tmp != NULL) {
ind ++;
tmp = tmp->next;
}
return ind;
}
struct dlist *dlist_get(struct dlist *l, size_t index){
struct dlist *tmp = l;
size_t ind = 0;
while(tmp != NULL && ind < index){
tmp = tmp->next;
ind ++;
}
return tmp;
}
//Test dlist_append
Test(double_suite, test_append){
struct dlist *l = NULL;
l = dlist_append(l, 3); // [3]
cr_assert_not_null(l, "la liste ne peux pas etre null apres un ajout");
cr_assert_eq(l->data, 3, "la data du 1er noeud doit être 3");
l = dlist_append(l, 2); // [2] <-> [3]
cr_assert_not_null(l->next, "le deuxieme noeud doit exister");
cr_assert_eq(l->data, 2, "Le premier noeud doit etre 2");
l = dlist_append(l, 1); // [1] <-> [2] <-> [3]
cr_assert_not_null(l->next, "le troisieme noeud doit exister");
cr_assert_eq(l->data, 1, "Le premier noeud doit etre 1");
cr_assert_eq(l->next->data, 2, "Le second noeud doit etre 2");
dlist_destroy(l);
}
Test(double_suite, test_insert){
struct dlist *l = NULL;
int res1 = dlist_insert(&l, 0, 100);
cr_assert_eq(res1, 0, "L'insertion à l'index 0 doit réussir.");
cr_assert_not_null(l, "La liste ne doit pas être NULL.");
cr_assert_eq(l->data, 100, "La valeur insérée doit être 100.");
int res2 = dlist_insert(&l, 5, 200);
cr_assert_eq(res2, 1, "Out of Range !");
dlist_destroy(l);
}
Test(double_suite, test_delete_at){
struct dlist *l = NULL;
l = dlist_append(l, 30);
l = dlist_append(l, 20);
l = dlist_append(l, 10); // [10] <-> [20] <-> [30]
struct dlist *rslt = NULL;
rslt = dlist_delete_at(&l, 1); // Retire le 20. l devient [10] -> [30]
cr_assert_not_null(rslt, "Le noeud retiré ne doit pas être NULL");
cr_assert_eq(rslt->data, 20, "La data du noeud supprimé doit etre de 20");
size_t count = dlist_count(l);
cr_assert_eq(count, 2, "La taille de la liste doit etre de 2");
struct dlist *tmp = dlist_get(l, 0);
cr_assert_not_null(tmp, "Le noeud 0 ne doit pas être NULL");
cr_assert_eq(tmp->data, 10, "La data du noeud 1 doit etre de 10");
tmp = dlist_get(l, 1);
cr_assert_not_null(tmp, "Le noeud 1 ne doit pas être NULL");
cr_assert_eq(tmp->data, 30, "La data du noeud 2 doit etre de 30");
tmp = dlist_get(l, 3);
cr_assert_null(tmp, "Le pointeur doit etre null");
dlist_destroy(l);
}
Test(double_suite, test_remove){
struct dlist *l = NULL;
l = dlist_append(l, 7);
l = dlist_append(l, 3);
l = dlist_append(l, 7);
l = dlist_append(l, 1); // [1] <-> [7] <-> [3] <-> [7]
int rm = dlist_remove(&l, 7); // Retire le premier 7. l devient [1] <-> [3] <-> [7]
cr_assert_eq(rm, 1, "Le noeud 7 doit etre supprimé");
struct dlist *tmp = dlist_get(l, 0);
cr_assert_not_null(tmp, "Le noeud 0 existe");
cr_assert_eq(tmp->data, 1, "Le noeud 1 a changé et devient 1 !");
tmp = dlist_get(l, 1);
cr_assert_not_null(tmp, "Le noeud 1 existe");
cr_assert_eq(tmp->data, 3, "Le noeud 2 doit etre egal a 3");
tmp = dlist_get(l, 2);
cr_assert_not_null(tmp, "Le noeud 2 existe");
cr_assert_eq(tmp->data,7, "Le 3 eme noeud doit etre de 7");
rm = dlist_remove(&l, 42);
cr_assert_eq(rm, 0, "Doit renvoyer 0 car 42 n'existe pas !");
dlist_destroy(l);
}