Révision 152
Ajouté par Pape Demba AMAR il y a environ 3 ans
main.c | ||
---|---|---|
}
|
||
return res;
|
||
}
|
||
|
||
int decode_int(char c) // cette fonction me permet de retourner -1 tant que le caract?re n'est pas compris entre 0 et 9 ou autre
|
||
{
|
||
int r;
|
||
if(c>=48 && c<=57)
|
||
{
|
||
r=c-48;
|
||
}
|
||
else
|
||
{
|
||
r=-1;
|
||
}
|
||
return r;
|
||
}
|
||
|
||
//Fonction ? modifier !!!!!
|
||
void traitement(char * trame)
|
||
{
|
||
static int cpt=0;
|
||
cpt++ ;
|
||
if(trame_cmp(trame,"GPGGA"))
|
||
if(trame_cmp(trame,"GPGGA")) //n'afficher que la trame GPGGA
|
||
printf ("> %s\n",trame);
|
||
}
|
||
|
||
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);
|
||
}
|
||
}
|
||
|
||
|
||
//Ajouter vos tests unitaires dans cette fonction.
|
||
void tests_unitaires(void){
|
||
void tests_unitaires(void){ // le test unitaire de la fonction trame_cmp
|
||
if (5!=5){
|
||
printf ("Erreur Test unitaire basique.\n");
|
||
exit(-1);
|
||
... | ... | |
if (trame_cmp("$APRMC...", "GPGGA")!=0){
|
||
printf ("Erreur Test unitaire trame_cmp4.\n");
|
||
exit(-1);
|
||
}
|
||
}
|
||
test_decode_int();
|
||
}
|
||
|
||
// Ne pas modifier cette fonction
|
Formats disponibles : Unified diff
implantation de la fonction décode_int et de son test