Optimiser F6 avec un index direct par identifiant

This commit is contained in:
rabot
2026-10-21 11:14:00 +02:00
parent 285afd80a7
commit 1c7970b554
3 changed files with 51 additions and 5 deletions
+24
View File
@@ -154,6 +154,29 @@ static void tester_periodes(void)
}
}
static void tester_recherches(void)
{
assert(rechercher_par_id(NULL, 0, 0) == NULL);
assert(rechercher_par_id(NULL, 0, -1) == NULL);
Transaction t[128];
const Transaction *index_ids[128];
for (int n = 1; n <= 128; n++) {
for (int i = 0; i < n; i++)
t[i] = (Transaction){n - 1 - i, i, i, i * 77 - 12};
indexer_par_id(t, n, index_ids);
for (int id = 0; id < n; id++) {
const Transaction *attendu = NULL;
for (int i = 0; i < n; i++)
if (t[i].id == id)
attendu = &t[i];
assert(rechercher_par_id(index_ids, n, id) == attendu);
}
assert(rechercher_par_id(index_ids, n, -1) == NULL);
assert(rechercher_par_id(index_ids, n, n) == NULL);
assert(rechercher_par_id(index_ids, n, INT_MAX) == NULL);
}
}
int main(void)
{
tester_tri();
@@ -161,6 +184,7 @@ int main(void)
tester_totaux_clients();
tester_totaux_jours();
tester_periodes();
tester_recherches();
puts("Tests banque : OK");
return 0;
}