From d8cd0c785b9586ca3808b8e93108cb1b1bed22d8 Mon Sep 17 00:00:00 2001 From: Louay DARDOURI Date: Tue, 4 Feb 2025 10:43:10 +0100 Subject: [PATCH] =?UTF-8?q?Ajout=20des=20tests=20pour=20les=20d=C3=A9penda?= =?UTF-8?q?nces=20circulaires=20avec=20les=20fichiers=20source.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- TODO.md | 3 ++- tests/test-03-circulaire/Bakefile | 14 ++++++++++++++ tests/test-03-circulaire/README.md | 3 +++ tests/test-03-circulaire/a.c | 12 ++++++++++++ tests/test-03-circulaire/a.h | 6 ++++++ tests/test-03-circulaire/b.c | 7 +++++++ tests/test-03-circulaire/b.h | 6 ++++++ tests/test-03-circulaire/c.c | 7 +++++++ tests/test-03-circulaire/c.h | 6 ++++++ 9 files changed, 63 insertions(+), 1 deletion(-) create mode 100644 tests/test-03-circulaire/Bakefile create mode 100644 tests/test-03-circulaire/README.md create mode 100644 tests/test-03-circulaire/a.c create mode 100644 tests/test-03-circulaire/a.h create mode 100644 tests/test-03-circulaire/b.c create mode 100644 tests/test-03-circulaire/b.h create mode 100644 tests/test-03-circulaire/c.c create mode 100644 tests/test-03-circulaire/c.h diff --git a/TODO.md b/TODO.md index 96625e6..ada3893 100644 --- a/TODO.md +++ b/TODO.md @@ -1,4 +1,5 @@ # Liste des choses à faire plus tard : - [ ] Améliorer les `README.md` des tests -- [ ] Ajouter le fichier compiler dans `test-02-exite-deja` \ No newline at end of file +- [ ] Ajouter le fichier compiler dans `test-02-exite-deja` +- [ ] Vérifier les commentaires -> si ça fait des erreurs (commentaire en plein milieu etc..) \ No newline at end of file diff --git a/tests/test-03-circulaire/Bakefile b/tests/test-03-circulaire/Bakefile new file mode 100644 index 0000000..369b433 --- /dev/null +++ b/tests/test-03-circulaire/Bakefile @@ -0,0 +1,14 @@ +main: a.o b.o c.o + gcc a.o b.o c.o -o main + +a.o: a.c a.h b.h + gcc -Wall -Werror -Wextra -c a.c -o a.o + +b.o: b.c b.h c.h + gcc -Wall -Werror -Wextra -c b.c -o b.o + +c.o: c.c c.h a.h + gcc -Wall -Werror -Wextra -c c.c -o c.o + +clean: + rm -f a.o b.o c.o main diff --git a/tests/test-03-circulaire/README.md b/tests/test-03-circulaire/README.md new file mode 100644 index 0000000..abaa797 --- /dev/null +++ b/tests/test-03-circulaire/README.md @@ -0,0 +1,3 @@ +# Test 3 : Dépendances circulaire + + diff --git a/tests/test-03-circulaire/a.c b/tests/test-03-circulaire/a.c new file mode 100644 index 0000000..3f49efe --- /dev/null +++ b/tests/test-03-circulaire/a.c @@ -0,0 +1,12 @@ +#include +#include "b.h" + +void functionA() { + printf("Function A called\n"); + functionB(); // Appelle une fonction de b.c +} + +int main() { + functionA(); + return 0; +} diff --git a/tests/test-03-circulaire/a.h b/tests/test-03-circulaire/a.h new file mode 100644 index 0000000..d53839a --- /dev/null +++ b/tests/test-03-circulaire/a.h @@ -0,0 +1,6 @@ +#ifndef A_H +#define A_H + +void functionA(); + +#endif diff --git a/tests/test-03-circulaire/b.c b/tests/test-03-circulaire/b.c new file mode 100644 index 0000000..b7da733 --- /dev/null +++ b/tests/test-03-circulaire/b.c @@ -0,0 +1,7 @@ +#include +#include "c.h" + +void functionB() { + printf("Function B called\n"); + functionC(); // Appelle une fonction de c.c +} diff --git a/tests/test-03-circulaire/b.h b/tests/test-03-circulaire/b.h new file mode 100644 index 0000000..321af19 --- /dev/null +++ b/tests/test-03-circulaire/b.h @@ -0,0 +1,6 @@ +#ifndef B_H +#define B_H + +void functionB(); + +#endif diff --git a/tests/test-03-circulaire/c.c b/tests/test-03-circulaire/c.c new file mode 100644 index 0000000..7e53ed3 --- /dev/null +++ b/tests/test-03-circulaire/c.c @@ -0,0 +1,7 @@ +#include +#include "a.h" + +void functionC() { + printf("Function C called\n"); + functionA(); // Appelle une fonction de a.c -> dépendance circulaire +} diff --git a/tests/test-03-circulaire/c.h b/tests/test-03-circulaire/c.h new file mode 100644 index 0000000..be34ba5 --- /dev/null +++ b/tests/test-03-circulaire/c.h @@ -0,0 +1,6 @@ +#ifndef C_H +#define C_H + +void functionC(); + +#endif