diff --git a/include/util.h b/include/util.h index 3bf935f..6087a3c 100644 --- a/include/util.h +++ b/include/util.h @@ -73,3 +73,8 @@ int Length(pile *p); void View(pile *); + + +//------------------------------------------------------------------------------ + +void util_pile_test(); // def: scr/util/tests diff --git a/src/fsm/measure.c b/src/fsm/measure.c index 796a612..07880b5 100644 --- a/src/fsm/measure.c +++ b/src/fsm/measure.c @@ -102,46 +102,7 @@ void fsm_add_measure (char *measure_name) {fsm_debug_msg (2, 0, measure_name, 2) void fsm_measures_list_init () { fsm_debug_msg (0,0, "fsm_measures_list_init()", 2); // sub_automaton 2 - - - -// https://chgi.developpez.com/liste/ < ^c^v - - - pile *MaPile = NULL; /* Impératif de l'initialiser à NULL */ - - Push(&MaPile, 10); - Push(&MaPile, 25); - Push(&MaPile, 33); - Push(&MaPile, 12); /* Empile 4 valeurs. */ - - puts("Affichage de la pile :"); - View(MaPile); /* Affiche la totalité de la pile. */ - puts("------"); - - printf("Nb d'elements : %d\n",Length(MaPile)); - puts("------"); - - puts("Deux valeurs soutirees de la pile :"); - printf("%d\n",Pop(&MaPile)); /* Affiche deux valeurs */ - printf("%d\n",Pop(&MaPile)); /* soutirées de la pile. */ - puts("------"); - - puts("Affichage de la pile :"); - View(MaPile); /* Affiche la totalité de la pile. */ - puts("------"); - - Clear(&MaPile); /* Vide la pile. */ - - Push(&MaPile, 18); /* Empile une valeur. */ - - puts("Affichage de la pile apres vidage et ajout d'une valeur :"); - View(MaPile); /* Affiche la totalité de la pile. */ - puts("------\n"); - - Clear(&MaPile); /* Vider la pile avant de quitter. */ - - + util_pile_test(); } diff --git a/src/util/list_2x_chained.c b/src/util/list_ch2x.c similarity index 85% rename from src/util/list_2x_chained.c rename to src/util/list_ch2x.c index 1ff5ce4..6c66dbf 100644 --- a/src/util/list_2x_chained.c +++ b/src/util/list_ch2x.c @@ -27,37 +27,16 @@ * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -#include + + #include #include - - - - - - - - -//------------------------------------------------------------------------------ -//------------------------------------------------------------------------------ -//------------------------------------------------------------------------------ -//------------------------------------------------------------------------------ -//------------------------------------------------------------------------------ -//------------------------------------------------------------------------------ -//------------------------------------------------------------------------------ -//------------------------------------------------------------------------------ -//------------------------------------------------------------------------------ // https://learntutorials.net/fr/c/topic/560/listes-liees < ^c^v vvv - - - - - struct doubly_node { struct doubly_node * prev; diff --git a/src/util/pile.c b/src/util/pile.c index 0afe5f3..4ee67db 100644 --- a/src/util/pile.c +++ b/src/util/pile.c @@ -29,13 +29,11 @@ -#include -#include -#include - #include "../../include/util.h" + + // https://chgi.developpez.com/liste/ < ^c^v diff --git a/src/util/tests.c b/src/util/tests.c new file mode 100644 index 0000000..2fa3024 --- /dev/null +++ b/src/util/tests.c @@ -0,0 +1,70 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * +* * +* Gem-graph client * +* * +* State machine * +* * +* Copyright © 2024 Libre en Communs * +* Copyright © 2024 Adrien Bourmault * +* Copyright © 2024 Jean Sirmai * +* * +* This file is part of Gem-graph. * +* * +* This program is free software: you can redistribute it and/or modify it * +* under the terms of the GNU Affero General Public License * +* as published by the Free Software Foundation, * +* either version 3 of the License, * +* or (at your option) any later version. * +* * +* This program is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; * +* without even the implied warranty of MERCHANTABILITY * +* or FITNESS FOR A PARTICULAR PURPOSE. * +* See the GNU Affero General Public License for more details. * +* * +* You should have received a copy of the GNU Affero General Public License * +* along with this program. If not, see . * +* * +* * * * * * * * * * * * * * * * * * * * * * * * * * */ + + +#include "../../include/util.h" + + + +void util_pile_test() // https://chgi.developpez.com/liste/ < ^c^v +{ + pile *MaPile = NULL; /* Impératif de l'initialiser à NULL */ + + Push(&MaPile, 10); + Push(&MaPile, 25); + Push(&MaPile, 33); + + Push(&MaPile, 12); /* Empile 4 valeurs. */ + + puts("Affichage de la pile :"); + View(MaPile); /* Affiche la totalité de la pile. */ + puts("------"); + + printf("Nb d'elements : %d\n",Length(MaPile)); + puts("------"); + + puts("Deux valeurs soutirees de la pile :"); + printf("%d\n",Pop(&MaPile)); /* Affiche deux valeurs */ + printf("%d\n",Pop(&MaPile)); /* soutirées de la pile. */ + puts("------"); + + puts("Affichage de la pile :"); + View(MaPile); /* Affiche la totalité de la pile. */ + puts("------"); + + Clear(&MaPile); /* Vide la pile. */ + + Push(&MaPile, 18); /* Empile une valeur. */ + + puts("Affichage de la pile apres vidage et ajout d'une valeur :"); + View(MaPile); /* Affiche la totalité de la pile. */ + puts("------\n"); + + Clear(&MaPile); /* Vider la pile avant de quitter. */ +}