introduction de src/util/... (util ? use ?...)

This commit is contained in:
Jean Sirmai 2024-08-24 10:52:28 +02:00
parent 085b165a6a
commit 07bafc912a
Signed by: jean
GPG Key ID: FB3115C340E057E3
5 changed files with 80 additions and 67 deletions

View File

@ -73,3 +73,8 @@ int Length(pile *p);
void View(pile *); void View(pile *);
//------------------------------------------------------------------------------
void util_pile_test(); // def: scr/util/tests

View File

@ -102,46 +102,7 @@ void fsm_add_measure (char *measure_name) {fsm_debug_msg (2, 0, measure_name, 2)
void fsm_measures_list_init () void fsm_measures_list_init ()
{ {
fsm_debug_msg (0,0, "fsm_measures_list_init()", 2); // sub_automaton 2 fsm_debug_msg (0,0, "fsm_measures_list_init()", 2); // sub_automaton 2
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. */
} }

View File

@ -27,37 +27,16 @@
* * * *
* * * * * * * * * * * * * * * * * * * * * * * * * * */ * * * * * * * * * * * * * * * * * * * * * * * * * * */
#include <stdbool.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
// https://learntutorials.net/fr/c/topic/560/listes-liees < ^c^v vvv // https://learntutorials.net/fr/c/topic/560/listes-liees < ^c^v vvv
struct doubly_node struct doubly_node
{ {
struct doubly_node * prev; struct doubly_node * prev;

View File

@ -29,13 +29,11 @@
#include <stdbool.h>
#include <stddef.h>
#include <gtk-4.0/gtk/gtk.h>
#include "../../include/util.h" #include "../../include/util.h"
// https://chgi.developpez.com/liste/ < ^c^v // https://chgi.developpez.com/liste/ < ^c^v

70
src/util/tests.c Normal file
View File

@ -0,0 +1,70 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * *
* *
* Gem-graph client *
* *
* State machine *
* *
* Copyright © 2024 Libre en Communs <contact@a-lec.org> *
* Copyright © 2024 Adrien Bourmault <neox@a-lec.org> *
* Copyright © 2024 Jean Sirmai <jean@a-lec.org> *
* *
* 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 <http://www.gnu.org/licenses/>. *
* *
* * * * * * * * * * * * * * * * * * * * * * * * * * */
#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. */
}