Projet Informatique Théorique 2016
Instructions et Documentation
test_automate_accessible.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 
25 int test_automate_accessible(){
26  int result = 1;
27 
28  {
29  Automate * automate = creer_automate();
30 
31  ajouter_transition( automate, 1, 'a', 1 );
32  ajouter_transition( automate, 1, 'b', 2 );
33  ajouter_etat_initial( automate, 1);
34  ajouter_etat_final( automate, 2);
35 
36  Automate * aut = automate_accessible( automate );
37 
38  TEST(
39  1
40  && aut
41  && le_mot_est_reconnu( aut, "b" )
42  && le_mot_est_reconnu( aut, "ab" )
43  && le_mot_est_reconnu( aut, "aab" )
44  && le_mot_est_reconnu( aut, "aaab" )
45  && ! le_mot_est_reconnu( aut, "" )
46  && ! le_mot_est_reconnu( aut, "a" )
47  && ! le_mot_est_reconnu( aut, "aa" )
48  && ! le_mot_est_reconnu( aut, "aaa" )
49  && ! le_mot_est_reconnu( aut, "aba" )
50  && ! le_mot_est_reconnu( aut, "abb" )
51  , result
52  );
53  liberer_automate( aut );
54  liberer_automate( automate );
55  }
56 
57  return result;
58 }
59 
60 
61 int main(){
62 
63  if( ! test_automate_accessible() ){ return 1; };
64 
65  return 0;
66 
67 }
Le type d'un automate.
Definition: automate.h:39
void liberer_automate(Automate *automate)
Détruit un automate.
Definition: automate.c:168
int le_mot_est_reconnu(const Automate *automate, const char *mot)
Renvoie vrai si le mot passé en paramètre est reconu par l'automate passé en paramètre, et renvoie 0 sinon.
Definition: automate.c:442
void ajouter_transition(Automate *automate, int origine, char lettre, int fin)
Ajoute une transition à l'automate passé en paramètre.
Definition: automate.c:206
Automate * creer_automate()
Crée un automate vide, sans états, sans lettres et sans transitions.
Definition: automate.c:91
Automate * automate_accessible(const Automate *automate)
Definition: automate.c:488
void ajouter_etat_final(Automate *automate, int etat_final)
Ajoute un état final à un automate passé en paramètre.
Definition: automate.c:226
void ajouter_etat_initial(Automate *automate, int etat_initial)
Ajoute un état initial à un automate passé en paramètre.
Definition: automate.c:233