Optimiser F10 en conservant la fin du rapport

This commit is contained in:
rabot
2026-10-21 11:23:07 +02:00
parent 3f98548446
commit f2eb2c2f1e
12 changed files with 590 additions and 123 deletions
+30
View File
@@ -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;
}