Optimiser F4 par accumulation directe des soldes journaliers

This commit is contained in:
rabot
2026-10-21 11:12:46 +02:00
parent 14c18a3975
commit b59e9700c7
3 changed files with 35 additions and 5 deletions
+23
View File
@@ -91,11 +91,34 @@ static void tester_totaux_clients(void)
assert(totaux[c] == 0);
}
static void tester_totaux_jours(void)
{
Transaction t[] = {
{0, 0, NB_JOURS - 1, 100}, {1, 1, 0, -50},
{2, 2, NB_JOURS - 1, -40}, {3, 3, 0, 50}, {4, 4, 7, 0}
};
long totaux[NB_JOURS];
for (int i = 0; i < NB_JOURS; i++)
totaux[i] = 123;
total_par_jour(t, 5, totaux);
for (int j = 0; j < NB_JOURS; j++) {
long attendu = 0;
for (int i = 0; i < 5; i++)
if (t[i].jour == j)
attendu += t[i].montant;
assert(totaux[j] == attendu);
}
total_par_jour(NULL, 0, totaux);
for (int j = 0; j < NB_JOURS; j++)
assert(totaux[j] == 0);
}
int main(void)
{
tester_tri();
tester_clients_distincts();
tester_totaux_clients();
tester_totaux_jours();
puts("Tests banque : OK");
return 0;
}