Projet Informatique Théorique 2016
Instructions et Documentation
test_creer_automate_determisite.c
1 /*
2  * Ce fichier fait partie d'un projet de programmation donné en Licence 3
3  * à l'Université de Bordeaux
4  *
5  * Copyright (C) 2015 Adrien Boussicault
6  *
7  * This Library is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 2 of the License, or
10  * (at your option) any later version.
11  *
12  * This Library is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this Library. If not, see <http://www.gnu.org/licenses/>.
19  */
20 
21 
22 #include "automate.h"
23 #include "outils.h"
24 #include "ensemble.h"
25 
26 #include <stdarg.h>
27 
28 int sont_dans_l_ensemble( int n, Ensemble * ens, ... ){
29  va_list pile;
30  int res = 1;
31  int i;
32  va_start(pile,ens);
33  for (i=0;i<n;i++){
34  res &= est_dans_l_ensemble( ens, va_arg(pile,int) );
35  }
36  va_end(pile);
37  return res;
38 }
39 
40 int l_ensemble_est_egal( int n, const Ensemble* ens, ... ){
41  va_list pile;
42  int res;
43  int i;
44 
45  Ensemble * e = creer_ensemble( NULL, NULL, NULL );
46 
47  va_start(pile,ens);
48  for (i=0;i<n;i++){
49  ajouter_element( e, va_arg(pile,int) );
50  }
51 
52  res = comparer_ensemble( ens, e );
53  liberer_ensemble( e );
54 
55  va_end(pile);
56  return res == 0;
57 }
58 
59 void action_test_transitions_automate(
60  int origine, char lettre, int fin, void* data
61 ){
62  int * res = (int*) data;
63  (*res) += 1;
64 }
65 
66 int test_transitions_automate( int nb_transitions, const Automate* aut, ... ){
67  va_list pile;
68  int i;
69  int nb = 0;
70  pour_toute_transition( aut, action_test_transitions_automate, &nb );
71  if( nb_transitions != nb ){ return 0; }
72 
73  va_start(pile,aut);
74  for (i=0;i<nb_transitions;i++){
75  int origine = va_arg(pile,int);
76  char lettre = (char) va_arg(pile,int);
77  int fin = va_arg(pile,int);
78  if(
80  aut, origine, lettre, fin
81  )
82  ){ return 0; }
83  }
84 
85  va_end(pile);
86  return 1;
87 }
88 
89 
90 int test_creer_automate_deterministe(){
91  int resultat = 1;
92  {
93 
94  TEST(
95  0
96  ,resultat
97  );
98  // N'oubliez pas de tester votre code !
99 
100  }
101 
102  return resultat;
103 };
104 
105 
106 
107 
108 int main(){
109 
110  if( ! test_creer_automate_deterministe() ){ return 1; }
111 
112  return 0;
113 }
Le type d'un automate.
Definition: automate.h:39
int est_une_transition_de_l_automate(const Automate *automate, int origine, char lettre, int fin)
Renvoie 1 si ('origine', 'lettre', 'fin') est une transition de l'automate et 0 sinon.
Definition: automate.c:392
void pour_toute_transition(const Automate *automate, void(*action)(int origine, char lettre, int fin, void *data), void *data)
La fonction passe en revue toutes les transitions de l'automate et appelle la fonction passée en para...
Definition: automate.c:294