Révision 269
Ajouté par Clement ROCHE il y a environ 3 ans
branch/ROCHE/sp4a12/main.c | ||
---|---|---|
|
||
}
|
||
|
||
float decode_lat_long (char c[]) {
|
||
int n=0, degre=0, cpt=0,i=-1;
|
||
float min=0, secondes=0, res=0;
|
||
|
||
|
||
do{
|
||
n++;
|
||
} while (c[n]!='.');
|
||
|
||
if (n==4) {
|
||
degre = (c[0]-48)*10+(c[1]-48);
|
||
min = (c[2]-48)*10+(c[3]-48);
|
||
} else {
|
||
degre = (c[0]-48)*100+(c[1]-48*10)+(c[2]-48);
|
||
min = (c[2]-48)*100+(c[3]-48)*10+(c[4]-48);
|
||
}
|
||
|
||
n++;
|
||
do {
|
||
secondes= secondes + (c[n]-48)*pow(10,i);
|
||
i--;
|
||
n++;
|
||
} while (c[n]!='\0');
|
||
|
||
res = degre + (min+secondes)/60;
|
||
|
||
return res;
|
||
|
||
}
|
||
|
||
|
||
|
||
//Ajouter vos tests unitaires dans cette fonction.
|
||
... | ... | |
printf("erreur");
|
||
exit(-1);
|
||
}
|
||
}
|
||
|
||
void test_decode_lat_long(void) {
|
||
if ((37,387458 - decode_lat_long("3723.2475") > 0.0001) && (37,387458 - decode_lat_long("3723.2475") < 0.0001)){
|
||
printf("erreur");
|
||
exit(-1);
|
||
}
|
||
if ((3,11006 - decode_lat_long("00306.6036") > 0.0001) && (3,11006 - decode_lat_long("00306.6036") < 0.0001)){
|
||
printf("erreur");
|
||
exit(-1);
|
||
}
|
||
|
||
}
|
||
|
||
... | ... | |
//test_decode_int();
|
||
//test_decode_nombre();
|
||
//test_decode_latitude();
|
||
test_decode_longitude();
|
||
//test_decode_longitude();
|
||
test_decode_lat_long();
|
||
|
||
// Affichage des trames definies dans la table trames.
|
||
printf ("Trames de tests tableau trames:\n");
|
Formats disponibles : Unified diff
fonction générique non testé