Révision 173
Ajouté par beclement2 il y a presque 4 ans
branch/CLEMENT/sp4a12/main.c | ||
---|---|---|
#include <stdio.h>
|
||
#include <stdlib.h>
|
||
#include <strings.h>
|
||
#include "trame.h"
|
||
#include "trame.h"
|
||
#include <math.h>
|
||
|
||
//Trames de tests ? modifier si n?cessaire.
|
||
char * trames[]= {"$GPGSV,3,2,10,15,03,077,,18,04,041,42,19,85,271,,20,08,214,*7C",
|
||
... | ... | |
|
||
|
||
}
|
||
|
||
|
||
|
||
int decode_int(char c){ /* Fonction permettant de transformer un code ASCII en d?cimale */
|
||
|
||
int res;
|
||
... | ... | |
|
||
}
|
||
|
||
void test_decode_int(void){
|
||
int test_decode_int(void){
|
||
|
||
char testchar = '2';
|
||
|
||
int test = decode_int(testchar);
|
||
|
||
printf("Le code est %d\n", test);
|
||
return test;
|
||
|
||
}
|
||
|
||
//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("$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_nombre(char * ch, int n){
|
||
|
||
int i;
|
||
int finale;
|
||
int temp;
|
||
for(i=0; i<n; i++){
|
||
|
||
finale = (pow(10, n-i-1)) * (decode_int(ch[i])) + temp;
|
||
temp = finale;
|
||
}
|
||
|
||
return finale;
|
||
|
||
}
|
||
|
||
int test_decode_nombre(){
|
||
|
||
|
||
char testchar[] = "7541";
|
||
int test = decode_nombre(testchar, 3);
|
||
return test;
|
||
|
||
}
|
||
|
||
//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("$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);
|
||
}
|
||
if(test_decode_int() != 2){
|
||
printf ("Erreur Test unitaire test_decode_int.\n");
|
||
exit(-1);
|
||
}
|
||
if(test_decode_nombre() != 754){
|
||
printf ("Erreur Test unitaire test_decode_nombre.\n");
|
||
exit(-1);
|
||
}
|
||
|
||
|
||
}
|
||
|
||
// Ne pas modifier cette fonction
|
||
int main(int argc,char ** argv)
|
||
{
|
||
test_decode_int();
|
||
|
||
tests_unitaires();
|
||
|
||
|
Formats disponibles : Unified diff
Fin question 8 (avec correction fonction test_unitaire de la question 7)