Révision 295
Ajouté par Romain CHAMBELLON il y a environ 3 ans
branch/CHAMBELLON/sp4a12/main.c | ||
---|---|---|
printf ("> %s\n",trame);
|
||
}
|
||
|
||
float conv_latitude(char* lat_sexa)
|
||
float conv_lat(char* lat_sex)
|
||
{
|
||
|
||
float lat_dec=0;
|
||
float degres_lat = decode_nombre(lat_sexa,4);
|
||
float degres_lat = decode_nombre(lat_sex,4);
|
||
int i;
|
||
for (i=5;i<9;i++)
|
||
{
|
||
degres_lat += (decode_int(lat_sexa[i]))*pow(10,-i+4);
|
||
degres_lat += (decode_int(lat_sex[i]))*pow(10,-i+4);
|
||
}
|
||
lat_dec = (int) (degres_lat/100);
|
||
lat_dec += (degres_lat-lat_dec*100)/60;
|
||
return lat_dec;
|
||
|
||
}
|
||
|
||
float conv_long (char* long_sex)
|
||
{
|
||
|
||
float long_dec=0;
|
||
float degres_long = decode_nombre(long_sex,5);
|
||
int i;
|
||
for (i=6;i<10;i++)
|
||
{
|
||
degres_long += (decode_int(long_sex[i]))*pow(10,-i+5);
|
||
}
|
||
long_dec = (int) (degres_long/100);
|
||
long_dec += (degres_long-long_dec*100)/60;
|
||
return long_dec;
|
||
|
||
}
|
||
|
||
void test_conversion(void)
|
||
{
|
||
if (fabs(conv_latitude("3723.2475")-37.387458)>= pow(10,-6)){
|
||
printf ("Erreur Test unitaire conv_latitude.\n");
|
||
if (fabs(conv_lat("3723.2475")-37.387458)>= pow(10,-6)){
|
||
printf ("Erreur Test unitaire conv_lat.\n");
|
||
exit(-1);
|
||
}
|
||
|
||
if (fabs(conv_long("00306.6036")-3.11006)>= pow(10,-6)){
|
||
printf ("Erreur Test unitaire conv_long.\n");
|
||
exit(-1);
|
||
}
|
||
}
|
||
|
||
//Ajouter vos tests unitaires dans cette fonction.
|
||
... | ... | |
test_decode_nombre();
|
||
|
||
test_conversion();
|
||
|
||
|
||
}
|
||
|
||
... | ... | |
// Ne pas modifier cette fonction
|
||
int main(int argc,char ** argv)
|
||
{
|
||
|
||
|
||
tests_unitaires();
|
||
|
Formats disponibles : Unified diff
Fin question 9 : fonction et test unitaire de la conversion de longitude sont implantés