Révision 155
Ajouté par Romain CHAMBELLON il y a environ 3 ans
branch/CHAMBELLON/sp4a12/main.c | ||
---|---|---|
|
||
int trame_cmp(char * trame, char * type)
|
||
{
|
||
|
||
int i = 0, j = 0, res = 1;
|
||
while(type[i] != '\0') // La boucle while s'execute tant que la chaine de caractere type n'a pas ?t? enti?rement lu
|
||
while(type[i] != '\0')
|
||
{
|
||
i++;
|
||
}
|
||
|
||
while(j<i) // Tant que la boucle while pr?c?dente s'ex?cute
|
||
while(j<i)
|
||
{
|
||
if (trame[j+1] != type[j]) // Le resultat devient faux si les caract?res diff?rent
|
||
if (trame[j+1] != type[j])
|
||
{
|
||
res = 0;
|
||
}
|
||
... | ... | |
return res;
|
||
}
|
||
|
||
|
||
|
||
void test_decode_int(void)
|
||
{
|
||
if(decode_int('0') != 0)
|
||
... | ... | |
exit(-1);
|
||
}
|
||
}
|
||
|
||
int decode_nombre (char * ch, int n)
|
||
{
|
||
int i, res = 0;
|
||
for (i=0;i<n;i++)
|
||
{
|
||
res = res*10 + decode_int(ch[i]);
|
||
}
|
||
return res;
|
||
}
|
||
|
||
void test_decode_nombre(void)
|
||
{
|
||
if (decode_nombre("7541",2)!=75)
|
||
{
|
||
printf("Erreur test unitaire decode_nombre.\n");
|
||
exit(-1);
|
||
}
|
||
if (decode_nombre("7541",3)!=754)
|
||
{
|
||
printf("Erreur test unitaire decode_nombre.\n");
|
||
exit(-1);
|
||
}
|
||
}
|
||
|
||
//Fonction ? modifier !!!!!
|
||
void traitement(char * trame)
|
||
... | ... | |
|
||
test_decode_int();
|
||
}
|
||
|
||
|
||
// Ne pas modifier cette fonction
|
||
int main(int argc,char ** argv)
|
||
{
|
||
|
||
tests_unitaires();
|
||
tests_unitaires();
|
||
|
||
test_decode_nombre();
|
||
|
||
// Affichage des trames definies dans la table trames.
|
||
printf ("Trames de tests tableau trames:\n");
|
Formats disponibles : Unified diff
Q7 : Implantation fonction decode_nombre / Mise en place de son test unitaire dans la fonction test_decode_nombre