Révision 271
Ajouté par Youssef MORSY il y a environ 3 ans
branch/MORSY/sp4a12/main.c | ||
---|---|---|
}
|
||
|
||
if(decode_int('5')!= 5){
|
||
printf ("Erreur Test unitaire trame_cmp.\n");
|
||
printf ("Erreur Test unitaire trame_cmp50.\n");
|
||
exit(-1);
|
||
}
|
||
int i=0;
|
||
for(i=0;i<=9;i++){
|
||
if(decode_int('i')!= i){
|
||
printf ("Erreur Test unitaire trame_cmp.\n");
|
||
exit(-1);
|
||
}
|
||
}
|
||
|
||
if(decode_int('a')!= -1){
|
||
printf ("Erreur Test unitaire trame_cmp.\n");
|
||
printf ("Erreur Test unitaire trame_cmp3.\n");
|
||
exit(-1);
|
||
}
|
||
}
|
||
|
||
|
||
int decode_nombre(char *ch,int n){
|
||
int x=strlen(ch);
|
||
int i=0;
|
||
int i,j,p;
|
||
int s=0;
|
||
for (i=0;i<n;i++){
|
||
p=1;
|
||
for(j=0;j<n-1-i;j++){
|
||
p=p*10;
|
||
}
|
||
int a=decode_int(ch[i]);
|
||
s=s+a*pow(10,n-i-1);
|
||
s=s+a*p;
|
||
}
|
||
return s;
|
||
}
|
||
void test_decode_nombre(void){
|
||
if (5!=5){
|
||
printf ("Erreur Test unitaire basique.\n");
|
||
exit(-1);
|
||
printf ("Erreur Test unitaire basique.\n");
|
||
exit(-1);
|
||
}
|
||
if (decode_nombre("35789",3)!=357){
|
||
printf ("Erreur Test unitaire trame_cmp.\n");
|
||
exit(-1);
|
||
printf ("Erreur Test unitaire trame_cmp1.\n");
|
||
exit(-1);
|
||
}
|
||
}
|
||
|
||
if (decode_nombre("25986452235",7)!=2598645){
|
||
printf ("Erreur Test unitaire trame_cmp.\n");
|
||
exit(-1);
|
||
printf ("Erreur Test unitaire trame_cmp2.\n");
|
||
exit(-1);
|
||
}
|
||
if (decode_nombre("2",1)!=2){
|
||
printf ("Erreur Test unitaire trame_cmp.\n");
|
||
exit(-1);
|
||
printf ("Erreur Test unitaire trame_cmp3.\n");
|
||
exit(-1);
|
||
}
|
||
if (decode_nombre("25986452235",7)==2578963){
|
||
printf ("Erreur Test unitaire trame_cmp.\n");
|
||
exit(-1);
|
||
printf ("Erreur Test unitaire trame_cmp4.\n");
|
||
exit(-1);
|
||
}
|
||
int l;
|
||
for (l=0;l<=1;l++){
|
||
if (decode_nombre("2",1)==i){
|
||
printf ("Erreur Test unitaire trame_cmp.\n");
|
||
exit(-1);
|
||
}
|
||
}
|
||
int j;
|
||
for (j=2;j<=9;j++){
|
||
if (decode_nombre("2",1)==i){
|
||
printf ("Erreur Test unitaire trame_cmp.\n");
|
||
exit(-1);
|
||
}
|
||
}
|
||
}
|
||
|
||
|
||
|
||
|
||
float latitude (char*c){
|
||
int i=0,degre;
|
||
float secondes=0,sommes,minute=0;
|
||
degre=decode_int(c[0])*10+decode_int(c[1]) ;
|
||
secondes=(decode_int(c[5])*1000+decode_int(c[6])*100+decode_int(c[7])*10+decode_int(c[5]))/10000;
|
||
minute=(decode_int(c[2])*10+decode_int(c[3])+secondes)/60;
|
||
sommes=degre+minute;
|
||
return sommes;
|
||
}
|
||
void test_latitude(void){
|
||
if (5!=5){
|
||
printf ("Erreur Test unitaire basique.\n");
|
||
exit(-1);
|
||
}
|
||
if (latitude("3558.8889")-35,981481<0.000001 && 35,981481-latitude("3558.8889")<0.000001){
|
||
printf ("Erreur Test unitaire trame_cmp1.\n");
|
||
exit(-1);
|
||
}
|
||
if (latitude("0112.1415")-01,202358<0.000001 && 01,202358-latitude("0112.1415")<0.000001){
|
||
printf ("Erreur Test unitaire trame_cmp2.\n");
|
||
exit(-1);
|
||
}
|
||
|
||
}
|
||
float longtitude (char*c){
|
||
int i=0,degre;
|
||
float secondes=0,sommes,minute=0;
|
||
degre=decode_int(c[0])*100+decode_int(c[1])*10+decode_int(c[2]) ;
|
||
secondes=(decode_int(c[6])*1000+decode_int(c[7])*100+decode_int(c[8])*10+decode_int(c[9])*1)%1000;
|
||
minute=(decode_int(c[3])*10+decode_int(c[4])+secondes)/60;
|
||
sommes=degre+minute;
|
||
}
|
||
void test_longtitude(void){
|
||
if (5!=5){
|
||
printf ("Erreur Test unitaire basique.\n");
|
||
exit(-1);
|
||
}
|
||
if (latitude("13558.8889")-135,981481<0.000001 && 135,981481-latitude("13558.8889")<0.000001){
|
||
printf ("Erreur Test unitaire trame_cmp1.\n");
|
||
exit(-1);
|
||
}
|
||
if (latitude("10112.1415")-101,202358<0.000001 && 101,202358-latitude("10112.1415")<0.000001){
|
||
printf ("Erreur Test unitaire trame_cmp2.\n");
|
||
exit(-1);
|
||
}
|
||
|
||
}
|
||
float deux_fonctions(char*c){
|
||
int i=0,degre;
|
||
float secondes=0,sommes,minute=0;
|
||
while(c[i] != '.'){
|
||
i=i+1;
|
||
}
|
||
if(i==4){
|
||
|
||
degre=decode_int(c[0])*10+decode_int(c[1]) ;
|
||
secondes=(decode_int(c[5])*1000+decode_int(c[6])*100+decode_int(c[7])*10+decode_int(c[5]))/10000;
|
||
minute=(decode_int(c[2])*10+decode_int(c[3])+secondes)/60;
|
||
sommes=degre+minute;}
|
||
else{
|
||
degre=decode_int(c[0])*100+decode_int(c[1])*10+decode_int(c[2]) ;
|
||
secondes=(decode_int(c[6])*1000+decode_int(c[7])*100+decode_int(c[8])*10+decode_int(c[9])*1)%1000;
|
||
minute=(decode_int(c[3])*10+decode_int(c[4])+secondes)/60;
|
||
sommes=degre+minute;
|
||
}
|
||
return sommes;
|
||
|
||
|
||
}
|
||
|
||
void test_deux_ions(void){
|
||
if (5!=5){
|
||
printf ("Erreur Test unitaire basique.\n");
|
||
exit(-1);
|
||
}
|
||
if (latitude("13558.8889")-135,981481<0.000001 && 135,981481-latitude("13558.8889")<0.000001){
|
||
printf ("Erreur Test unitaire trame_cmp1.\n");
|
||
exit(-1);
|
||
}
|
||
if (latitude("10112.1415")-101,202358<0.000001 && 101,202358-latitude("10112.1415")<0.000001){
|
||
printf ("Erreur Test unitaire trame_cmp2.\n");
|
||
exit(-1);
|
||
}
|
||
// Ne pas modifier cette fonction
|
||
int main(int argc,char ** argv)
|
||
{
|
||
|
||
tests_unitaires();
|
||
tests_unitaires();
|
||
test_decode_int();
|
||
test_decode_nombre();
|
||
test_latitude();
|
||
test_longtitude();
|
||
|
||
|
||
|
||
// Affichage des trames definies dans la table trames.
|
||
printf ("Trames de tests tableau trames:\n");
|
||
int i=0;
|
Formats disponibles : Unified diff
fin question 9 et j'ai commence le 10