flisp/src/main.c
2025-03-04 23:59:54 +01:00

62 lines
1.3 KiB
C

#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include <stdio.h>
#include "types.h"
#include "byte_defs.h"
#include "hash.h"
#define STR_N 20
int main(){
HashMap map;
if(heap_hashmap(&map, 256)){
printf("Failed to alloc hashmap");
return 1;
}
char *strings[] = {
"Je mange fromage",
"Les chausettes de l'archiducess",
"sont elles seches, archiseches",
"Now, for something completly dif",
"ferent.",
"Nobody expects the spanish inqui",
"sition !",
"Il est 4H du matin",
"very-long-and-verbose-function",
"Mais punaise de flute",
"Mais ou sont passes le couteau",
"et le bebe ?!",
"Surement le bebe ne peut pas",
"trouver les explosifs ici",
"Panoramix a fait de la potion",
"Pourquoi est ce que je ne peux",
"pas avoir une mitrailleuse",
"123456789ABCDEFGHIJKLMNOPQRSTUVX",
"a",
"b"
};
char *strings2[STR_N];
int hashs[STR_N];
for(int i = 0; i < STR_N; i++)
hashs[i] = hashmap_insert(&map, strings[i]);
for(int i = 0; i < STR_N; i++){
strings2[i] = hashmap_get(&map, hashs[i]);
printf("%d : %s\n", hashs[i], strings2[i]);
}
i32 res = 0;
for(int i = 0; i < STR_N; i++){
res += strncmp(strings[i], strings2[i], 32);
}
assert(!res);
free_hashmap(&map);
return 0;
}