Révision 327
Ajouté par Papa Abdoulaye NDIAYE il y a environ 3 ans
branch/papa_ndiaye/sp4a12/main.c | ||
---|---|---|
#include <stdio.h>
|
||
#include <stdlib.h>
|
||
#include <strings.h>
|
||
#include <strings.h>
|
||
#include <math.h>
|
||
#include "trame.h"
|
||
#define nbtrames 8
|
||
|
||
int decode_int(char c)
|
||
{
|
||
int resu;
|
||
if(c<'0' && c>'9')
|
||
resu=-1;
|
||
else
|
||
resu=c-48;
|
||
return resu;
|
||
}
|
||
|
||
int decode_nombre(char * ch , int n)
|
||
{
|
||
int s;
|
||
for(int i=0;i<n;i++)
|
||
{
|
||
s=s+ decode_int(ch[n-1+i])*pow(10,n);
|
||
}
|
||
|
||
return s;
|
||
|
||
}
|
||
int trame_cmp(char * trame, char * type)
|
||
{
|
||
int i=4,resu =1;
|
||
... | ... | |
|
||
|
||
}
|
||
|
||
void test_decode_int(void)
|
||
{
|
||
if (5!=5){
|
||
printf ("Erreur Test unitaire basique.\n");
|
||
exit(-1);
|
||
}
|
||
|
||
if (decode_int('6')==-1){
|
||
printf ("Erreur Test unitaire trame_cmp.\n");
|
||
exit(-1);
|
||
}
|
||
|
||
}
|
||
void test_decode_nombre(char * ch, int n)
|
||
{
|
||
int s=decode_nombre(ch, n);
|
||
for(int i=0;i<n;i++)
|
||
{
|
||
s=s- decode_int(ch[n-1+i])*pow(10,n);
|
||
}
|
||
if (5!=5){
|
||
printf ("Erreur Test unitaire basique.\n");
|
||
exit(-1);
|
||
}
|
||
|
||
if (s!=0){
|
||
printf ("Erreur Test unitaire trame_cmp.\n");
|
||
exit(-1);
|
||
}
|
||
|
||
}
|
||
//Ajouter vos tests unitaires dans cette fonction.
|
||
void tests_unitaires(void){
|
||
if (5!=5){
|
Formats disponibles : Unified diff
rectification question 6 et question 7 faite