Révision 77
Ajouté par Yannis SENOUCI il y a environ 3 ans
branch/SENOUCI/sp4a12/main.c | ||
---|---|---|
int decode_int(char c)
|
||
{
|
||
int nb;
|
||
|
||
nb = c-48;
|
||
|
||
if((nb<0)|(nb>9))
|
||
if((nb<0)||(nb>9))
|
||
{
|
||
return -1;
|
||
}
|
||
... | ... | |
}
|
||
}
|
||
|
||
int decode_nombre(char *ch,int n)
|
||
{
|
||
int res=0;
|
||
int i;
|
||
for(i=0;i<n;i++)
|
||
{
|
||
res=(res*10)+decode_int(ch[i]);
|
||
}
|
||
return res;
|
||
}
|
||
|
||
|
||
//Ajouter vos tests unitaires dans cette fonction.
|
||
void tests_unitaires(void){
|
||
... | ... | |
}
|
||
if (trame_cmp("$APRMC...", "GPGGA")!=0){
|
||
printf ("Erreur Test unitaire trame_cmp.\n");
|
||
exit(-1);
|
||
}
|
||
if(decode_int('5')!=5){
|
||
printf ("Erreur Test unitaire decode int.\n");
|
||
exit(-1);
|
||
}
|
||
if(decode_nombre("7558",2)!=75){
|
||
printf ("Erreur Test unitaire decode nombre.\n");
|
||
exit(-1);
|
||
}
|
||
}
|
||
|
Formats disponibles : Unified diff
implementation fct decode nombre et test qu7