forked from menault/2026_TD3_DEV51_Qualite_Algo
Optimiser F10 en conservant la fin du rapport
This commit is contained in:
@@ -273,6 +273,35 @@ static void tester_categories(void)
|
||||
}
|
||||
}
|
||||
|
||||
static void tester_rapport(void)
|
||||
{
|
||||
char rapport[4097] = "";
|
||||
char attendu[4097] = "";
|
||||
char *fin = rapport;
|
||||
size_t taille = 0;
|
||||
assert(ajouter_ligne(fin, "") == fin);
|
||||
for (int i = 0; i < 200; i++) {
|
||||
char ligne[20];
|
||||
int longueur_ligne = snprintf(ligne, sizeof(ligne), "ligne;%d\n", i);
|
||||
assert(longueur_ligne > 0);
|
||||
assert((size_t)longueur_ligne < sizeof(ligne));
|
||||
memcpy(attendu + taille, ligne, (size_t)longueur_ligne + 1);
|
||||
taille += (size_t)longueur_ligne;
|
||||
fin = ajouter_ligne(fin, ligne);
|
||||
assert(fin == rapport + taille);
|
||||
assert(*fin == '\0');
|
||||
assert(strcmp(rapport, attendu) == 0);
|
||||
assert(ajouter_ligne(fin, "") == fin);
|
||||
}
|
||||
char longue_ligne[4097];
|
||||
memset(longue_ligne, 'x', sizeof(longue_ligne) - 1);
|
||||
longue_ligne[sizeof(longue_ligne) - 1] = '\0';
|
||||
rapport[0] = '\0';
|
||||
fin = ajouter_ligne(rapport, longue_ligne);
|
||||
assert(fin == rapport + sizeof(rapport) - 1);
|
||||
assert(strcmp(rapport, longue_ligne) == 0);
|
||||
}
|
||||
|
||||
int main(void)
|
||||
{
|
||||
tester_tri();
|
||||
@@ -284,6 +313,7 @@ int main(void)
|
||||
tester_paires();
|
||||
tester_monnaie();
|
||||
tester_categories();
|
||||
tester_rapport();
|
||||
puts("Tests banque : OK");
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user