Skip to content
Extraits de code Groupes Projets
Valider 755cb41f rédigé par Loïc Wikle DUBARD's avatar Loïc Wikle DUBARD
Parcourir les fichiers

test make_list_index

parent 3380f6e8
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
Fichier ajouté
Aucun aperçu pour ce type de fichier
Fichier ajouté
Aucun aperçu pour ce type de fichier
...@@ -11,7 +11,7 @@ open Printf;; ...@@ -11,7 +11,7 @@ open Printf;;
exception InvalidTest;; exception InvalidTest;;
printf "======DEBUT DES TESTS======\n";; printf "======DEBUT DES TESTS======\n";;
printf "------Tests de la phase 1------\n";; printf "------Tests de la phase 1------\n\n";;
(* Test de tourner c n roue *) (* Test de tourner c n roue *)
printf " Fonction [tourner c n roue]\n";; printf " Fonction [tourner c n roue]\n";;
printf "Test tourner une roue vide.....";; printf "Test tourner une roue vide.....";;
...@@ -73,27 +73,136 @@ let rec test_tourner_2 n = ...@@ -73,27 +73,136 @@ let rec test_tourner_2 n =
test_tourner_2 27;; test_tourner_2 27;;
(*Test de char_to_index i c roue *)
printf " Fonction [char_to_index i c roue]\n";;
printf "indice d'un caractère invalide 'a' dans la roue initiale.....";;
try( let _ = char_to_index 0 'a' roue in () )
with
| BadCharacter -> printf "fait\n"
| _ -> raise InvalidTest
;;
let rec test_char_to_index_1 n =
if n>0 then (
let c = List.nth roue (27-n) in (
printf "recupération de l'indice de '%c' dans la roue initiale....." c;
if (char_to_index 0 c roue) = (27-n)
then (printf "fait\n";test_char_to_index_1 (n-1))
else raise InvalidTest
)
) else (
printf "\n"
);;
test_char_to_index_1 27;;
(*Test de translate c roue*) (*Test de translate c roue*)
let list_test_translate =
[("E",0);("NE",1);("NNE",2);("NNNE",3);("NNNNE",4);("NNNNNE",5);("NNNNNNE",6);("NNNNNNNE",7);("NNNNNNNNE",8);("NNNNNNNNNE",9);("NNNNNNNNNNE",10);("NNNNNNNNNNNE",11);("NNNNNNNNNNNNE",12);("NNNNNNNNNNNNNE",13);("PPPPPPPPPPPPPE",13);("PPPPPPPPPPPPE",12);("PPPPPPPPPPPE",11);("PPPPPPPPPPE",10);("PPPPPPPPPE",9);("PPPPPPPPE",8);("PPPPPPPE",7);("PPPPPPE",6);("PPPPPE",5);("PPPPE",4);("PPPE",3);("PPE",2);("PE",1);("E",0)];;
printf " Fonction [translate c roue]\n";; printf " Fonction [translate c roue]\n";;
let rec test_translate_1 n =
if n>0 then (
let caract = List.nth roue (27-n) in (
printf "Traduire '%c' avec la roue initiale....." caract;
if (translate caract roue) = (List.nth list_test_translate (27-n))
then (printf "fait\n";test_translate_1 (n-1))
else (raise InvalidTest)
)
)
else (
printf "\n"
);;
test_translate_1 27;;
(*Test de char_to_index i c roue *)
(*test de commande (i,l) roue *) (*test de commande (i,l) roue *)
printf " Fonction [commande (i,l) roue]\n";;
let m = "BONJOUR";;
printf "Envoie du message '%s'....." m;;
if (commande (1,(split_string m)) roue) = "NNENNNNNNNNNNNNNEPEPPPPENNNNNENNNNNNEPPPE" then (printf "fait\n") else (raise InvalidTest);;
(*Test de temps_lettre l*) let m = "LES EXTRATERRESTRES";;
printf "Envoie du message '%s'....." m;;
if (commande (1,(split_string m)) roue) = "NNNNNNNNNNNNEPPPPPPPEPPPPPPPPPPPPPENNNNNNNNENNNNNEPPPPPPPPEPPPPEPPENNNNNNNNNNEPPPPPPPPENNNNNNNNNNNNENNNNNNNNNNNNNEEPPPPPPPPPPPPPEPPPPPPPPPPPPPENEPPEPPPPPPPPPPPPPEPPPPPPPPPPPPPE" then (printf "fait\n") else (raise InvalidTest);;
(*test temps_commande s*)
let m = "ENSIIE";;
printf "Envoie du message '%s'....." m;;
if (commande (1,(split_string m)) roue) = "NNNNNENNNNNNNNNENNNNNEPPPPPPPPPPEEPPPPE" then (printf "fait\n") else (raise InvalidTest);;
printf "\n------Tests de la phase 2------\n\n";;
(*Test make_liste_index l c*) (*Test make_liste_index l c*)
printf " Fonction [make_list_index l c]\n";;
let list_test_index = [
[0;26;25;24;23;22;21;20;19;18;17;16;15;14;13;12;11;10;9;8;7;6;5;4;3;2;1;0];
[1;0;26;25;24;23;22;21;20;19;18;17;16;15;14;13;12;11;10;9;8;7;6;5;4;3;2;1];
[2;1;0;26;25;24;23;22;21;20;19;18;17;16;15;14;13;12;11;10;9;8;7;6;5;4;3;2];
[3;2;1;0;26;25;24;23;22;21;20;19;18;17;16;15;14;13;12;11;10;9;8;7;6;5;4;3];
[4;3;2;1;0;26;25;24;23;22;21;20;19;18;17;16;15;14;13;12;11;10;9;8;7;6;5;4];
[5;4;3;2;1;0;26;25;24;23;22;21;20;19;18;17;16;15;14;13;12;11;10;9;8;7;6;5];
[6;5;4;3;2;1;0;26;25;24;23;22;21;20;19;18;17;16;15;14;13;12;11;10;9;8;7;6];
[7;6;5;4;3;2;1;0;26;25;24;23;22;21;20;19;18;17;16;15;14;13;12;11;10;9;8;7];
[8;7;6;5;4;3;2;1;0;26;25;24;23;22;21;20;19;18;17;16;15;14;13;12;11;10;9;8];
[9;8;7;6;5;4;3;2;1;0;26;25;24;23;22;21;20;19;18;17;16;15;14;13;12;11;10;9];
[10;9;8;7;6;5;4;3;2;1;0;26;25;24;23;22;21;20;19;18;17;16;15;14;13;12;11;10];
[11;10;9;8;7;6;5;4;3;2;1;0;26;25;24;23;22;21;20;19;18;17;16;15;14;13;12;11];
[12;11;10;9;8;7;6;5;4;3;2;1;0;26;25;24;23;22;21;20;19;18;17;16;15;14;13;12];
[13;12;11;10;9;8;7;6;5;4;3;2;1;0;26;25;24;23;22;21;20;19;18;17;16;15;14;13];
[14;13;12;11;10;9;8;7;6;5;4;3;2;1;0;26;25;24;23;22;21;20;19;18;17;16;15;14];
[15;14;13;12;11;10;9;8;7;6;5;4;3;2;1;0;26;25;24;23;22;21;20;19;18;17;16;15];
[16;15;14;13;12;11;10;9;8;7;6;5;4;3;2;1;0;26;25;24;23;22;21;20;19;18;17;16];
[17;16;15;14;13;12;11;10;9;8;7;6;5;4;3;2;1;0;26;25;24;23;22;21;20;19;18;17];
[18;17;16;15;14;13;12;11;10;9;8;7;6;5;4;3;2;1;0;26;25;24;23;22;21;20;19;18];
[19;18;17;16;15;14;13;12;11;10;9;8;7;6;5;4;3;2;1;0;26;25;24;23;22;21;20;19];
[20;19;18;17;16;15;14;13;12;11;10;9;8;7;6;5;4;3;2;1;0;26;25;24;23;22;21;20];
[21;20;19;18;17;16;15;14;13;12;11;10;9;8;7;6;5;4;3;2;1;0;26;25;24;23;22;21];
[22;21;20;19;18;17;16;15;14;13;12;11;10;9;8;7;6;5;4;3;2;1;0;26;25;24;23;22];
[23;22;21;20;19;18;17;16;15;14;13;12;11;10;9;8;7;6;5;4;3;2;1;0;26;25;24;23];
[24;23;22;21;20;19;18;17;16;15;14;13;12;11;10;9;8;7;6;5;4;3;2;1;0;26;25;24];
[25;24;23;22;21;20;19;18;17;16;15;14;13;12;11;10;9;8;7;6;5;4;3;2;1;0;26;25];
[26;25;24;23;22;21;20;19;18;17;16;15;14;13;12;11;10;9;8;7;6;5;4;3;2;1;0;26];
];;
let rec test_make_liste_index n =
if n>0 then (
printf "liste des indices de '%c' dans chaque roue de la liste de toutes les roues possible....." (List.nth roue (27-n));
if (make_liste_index list_test_roues (List.nth roue (27-n))) = (List.nth list_test_index (27-n))
then (printf "fait\n"; test_make_liste_index (n-1))
else (raise InvalidTest)
) else ( printf "\n");;
test_make_liste_index 27;;
(*Test quelle_roue l c index_init*) (*Test quelle_roue l c index_init*)
printf " Fonction [quelle_roue l c i]\n";;
(*test tourner_list c n i l *) (*test tourner_list c n i l *)
printf " Fonction [tourner_list c n i l]\n";;
(*test initialize_list n a*) (*test initialize_list n a*)
printf " Fonction [initialize_list n a]\n";;
(*test commande2 (n,m) *) (*test commande2 (n,m) *)
printf " Fonction [commande2 (n,m)]\n";;
let m = "BONJOUR";;
printf "Envoie du message '%s'....." m;;
if (commande2 (3,(split_string m))) = "NNES1PPPPPPPPPPPPEPEPPPPENNNNNENNNNNNEPPPE" then (printf "fait\n") else (raise InvalidTest);;
let m = "LES EXTRATERRESTRES";;
printf "Envoie du message '%s'....." m;;
if (commande2 (4,(split_string m))) =
"NNNNNNNNNNNNES1NNNNNES0NNNNNNNES2ES1ES2PPPES0NEPPES3NES0NNES1ES0PPEES1ES0NENEPPES1ES0NE" then (printf "fait\n") else (raise InvalidTest);;
let m = "ENSIIE";;
printf "Envoie du message '%s'....." m;;
if (commande2 (2,(split_string m))) = "NNNNNENNNNNNNNNENNNNNES1NNNNNNNNNEEPPPPE" then (printf "fait\n") else (raise InvalidTest);;
printf "======FIN DES TESTS=======\n";; printf "======FIN DES TESTS=======\n";;
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter