Révision 151
Ajouté par Romain CHAMBELLON il y a environ 3 ans
main.c | ||
---|---|---|
"$GPGSA,A,3,,03,,22,14,,01,,18,,,,3.9,3.4,1.9*39",
|
||
"$GPVTG,99.4,T,,M,0.4,N,0.7,K*57",
|
||
"$GPZDA,141914.00,01,02,2006,00,00*69",
|
||
0};
|
||
0};
|
||
|
||
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 le char type n'a pas ?t? enti?rement lu
|
||
while(type[i] != '\0') // La boucle while s'execute tant que la chaine de caractere type n'a pas ?t? enti?rement lu
|
||
{
|
||
i++;
|
||
}
|
||
|
||
while(j<i)
|
||
while(j<i) // Tant que la boucle while pr?c?dente s'ex?cute
|
||
{
|
||
if (trame[j+1] != type[j]) // Le resultat devient faux
|
||
if (trame[j+1] != type[j]) // Le resultat devient faux si les caract?res diff?rent
|
||
{
|
||
res = 0;
|
||
}
|
||
... | ... | |
}
|
||
return res;
|
||
}
|
||
int decode_int(char c)
|
||
{
|
||
int res;
|
||
if (c >= 48 && c <= 57)
|
||
{
|
||
res = c - 48;
|
||
}
|
||
else
|
||
{
|
||
res = -1;
|
||
}
|
||
return res;
|
||
}
|
||
|
||
|
||
|
||
void test_decode_int(void)
|
||
{
|
||
if(decode_int('0') != 0)
|
||
{
|
||
printf ("Erreur Test unitaire decode_int.\n");
|
||
exit(-1);
|
||
}
|
||
if(decode_int('1') != 1)
|
||
{
|
||
printf ("Erreur Test unitaire decode_int.\n");
|
||
exit(-1);
|
||
}
|
||
if(decode_int('2') != 2)
|
||
{
|
||
printf ("Erreur Test unitaire decode_int.\n");
|
||
exit(-1);
|
||
}
|
||
if(decode_int('3') != 3)
|
||
{
|
||
printf ("Erreur Test unitaire decode_int.\n");
|
||
exit(-1);
|
||
}
|
||
if(decode_int('4') != 4)
|
||
{
|
||
printf ("Erreur Test unitaire decode_int.\n");
|
||
exit(-1);
|
||
}
|
||
if(decode_int('5') != 5)
|
||
{
|
||
printf ("Erreur Test unitaire decode_int.\n");
|
||
exit(-1);
|
||
}
|
||
if(decode_int('6') != 6)
|
||
{
|
||
printf ("Erreur Test unitaire decode_int.\n");
|
||
exit(-1);
|
||
}
|
||
if(decode_int('7') != 7)
|
||
{
|
||
printf ("Erreur Test unitaire decode_int.\n");
|
||
exit(-1);
|
||
}
|
||
if(decode_int('8') != 8)
|
||
{
|
||
printf ("Erreur Test unitaire decode_int.\n");
|
||
exit(-1);
|
||
}
|
||
if(decode_int('9') != 9)
|
||
{
|
||
printf ("Erreur Test unitaire decode_int.\n");
|
||
exit(-1);
|
||
}
|
||
if(decode_int('L') != (-1))
|
||
{
|
||
printf ("Erreur Test unitaire decode_int.\n");
|
||
exit(-1);
|
||
}
|
||
}
|
||
|
||
//Fonction ? modifier !!!!!
|
||
void traitement(char * trame)
|
||
... | ... | |
static int cpt=0;
|
||
cpt++;
|
||
if (trame_cmp(trame,"GPGGA"))
|
||
printf ("> %s\n",trame);
|
||
|
||
printf ("> %s\n",trame);
|
||
}
|
||
|
||
//Ajouter vos tests unitaires dans cette fonction.
|
||
void tests_unitaires(void){
|
||
void tests_unitaires(void)
|
||
{
|
||
if (5!=5){
|
||
printf ("Erreur Test unitaire basique.\n");
|
||
exit(-1);
|
||
... | ... | |
if (trame_cmp("$APRMC...", "GPGGA")!=0){
|
||
printf ("Erreur Test unitaire trame_cmp 4.\n");
|
||
exit(-1);
|
||
}
|
||
}
|
||
|
||
test_decode_int();
|
||
}
|
||
|
||
// Ne pas modifier cette fonction
|
Formats disponibles : Unified diff
Q6 : Implantation fonction decode_int / Mise en place exhaustive des tests unitaires associés, dans la fonction test_decode_int