summaryrefslogtreecommitdiffhomepage
path: root/src/3p/chibicc/hashmap.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/3p/chibicc/hashmap.c')
-rw-r--r--src/3p/chibicc/hashmap.c31
1 files changed, 0 insertions, 31 deletions
diff --git a/src/3p/chibicc/hashmap.c b/src/3p/chibicc/hashmap.c
index 46539d9..47110c6 100644
--- a/src/3p/chibicc/hashmap.c
+++ b/src/3p/chibicc/hashmap.c
@@ -132,34 +132,3 @@ void hashmap_delete2(HashMap *map, char *key, int keylen) {
if (ent)
ent->key = TOMBSTONE;
}
-
-void hashmap_test(void) {
- HashMap *map = calloc(1, sizeof(HashMap));
-
- for (int i = 0; i < 5000; i++)
- hashmap_put(map, format("key %d", i), (void *)(size_t)i);
- for (int i = 1000; i < 2000; i++)
- hashmap_delete(map, format("key %d", i));
- for (int i = 1500; i < 1600; i++)
- hashmap_put(map, format("key %d", i), (void *)(size_t)i);
- for (int i = 6000; i < 7000; i++)
- hashmap_put(map, format("key %d", i), (void *)(size_t)i);
-
- for (int i = 0; i < 1000; i++)
- assert((size_t)hashmap_get(map, format("key %d", i)) == i);
- for (int i = 1000; i < 1500; i++)
- assert(hashmap_get(map, "no such key") == NULL);
- for (int i = 1500; i < 1600; i++)
- assert((size_t)hashmap_get(map, format("key %d", i)) == i);
- for (int i = 1600; i < 2000; i++)
- assert(hashmap_get(map, "no such key") == NULL);
- for (int i = 2000; i < 5000; i++)
- assert((size_t)hashmap_get(map, format("key %d", i)) == i);
- for (int i = 5000; i < 6000; i++)
- assert(hashmap_get(map, "no such key") == NULL);
- for (int i = 6000; i < 7000; i++)
- hashmap_put(map, format("key %d", i), (void *)(size_t)i);
-
- assert(hashmap_get(map, "no such key") == NULL);
- printf("OK\n");
-}