Projet

Général

Profil

« Précédent | Suivant » 

Révision 258

Ajouté par Jordan MORARD il y a environ 3 ans

Fonction test unitaire, decode_int et test_decode_nombre terminé

Voir les différences:

branch/MORARD_Jordan/main.c
void traitement(char * trame)
{
static int cpt=0;
cpt++;
printf ("> %s\n",trame);
}
if (trame_cmp(trame, "GPGGA")==1)
{
printf ("> %s\n",trame);
cpt++;
}
}
int trame_cmp(char * trame,char * type)
{
int i;
int retour=1;
for(i=0;i<5;i++)
{
if(trame[i + 1]!=type[i])
{
retour=0;
}
}
return retour;
}
//Ajouter vos tests unitaires dans cette fonction.
void tests_unitaires(void){
if (5!=5){
printf ("Erreur Test unitaire basique.\n");
exit(-1);
}
/*if (trame_cmp("$GPGGA suite chaine","GPGGA")!=1){
printf ("Erreur Test unitaire trame_cmp.\n");
exit(-1);
}*/
}
}
/*if (trame_cmp("$GPGGA suite chaine","GPGGA")!=1){
printf ("Erreur Test unitaire trame_cmp.\n");
exit(-1);
}
if (trame_cmp("$GPRMC suite chaine","GPGGA")!=0){
printf ("Erreur Test unitaire trame_cmp.\n");
exit(-1);
}
if (trame_cmp("$GPRMC... ", "GPRMC" )!=1){
printf ("Erreur Test unitaire trame_cmp.\n");
exit(-1);
}
if (trame_cmp("$APRMC...", "GPGGA")!=0){
printf ("Erreur Test unitaire trame_cmp.\n");
exit(-1);*/
}
int decode_int(char c)
{
int nb;
nb = c-48;
if((nb<0)|(nb>9))
{
return -1;
}
else
{
return nb;
}
}
int test_decode_int()
{
int retour = 1;
if (decode_int('0')!=0)
{
retour = 0;
}
if (decode_int('1')!=0)
{
retour = 0;
}
if (decode_int('2')!=0)
{
retour = 0;
}
if (decode_int('3')!=0)
{
retour = 0;
}
if (decode_int('4')!=0)
{
retour = 0;
}
if (decode_int('5')!=0)
{
retour = 0;
}
if (decode_int('6')!=0)
{
retour = 0;if (decode_int('0')!=0)
{
retour = 0;
}
}
if (decode_int('7')!=0)
{
retour = 0;
}
if (decode_int('8')!=0)
{
retour = 0;
}
if (decode_int('9')!=0)
{
retour = 0;
}
return retour;
}
// Ne pas modifier cette fonction
int main(int argc,char ** argv)
{

Formats disponibles : Unified diff