-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest-hashes.cpp
More file actions
33 lines (27 loc) · 801 Bytes
/
test-hashes.cpp
File metadata and controls
33 lines (27 loc) · 801 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#define GHASHSET_HASH(hash, x) hash_len(hash, x)
#include "ghashset.h"
#include "gutils.h"
#include "assert.h"
int main()
{
gHashSet hashset = {};
gHashSet *h = &hashset;
gHashSet_ctor(h, 250, NULL);
FILE *inp = fopen("../texts/War-And-Peace.txt", "r");
size_t len = MAX_KEY_LEN / 10 + rand() % 60;
size_t new_len = len;
size_t status = len;
while (status == len) {
len = new_len;
fprintf(stdout, "len = %zu\n", len);
char key[MAX_KEY_LEN] = {};
status = fread(key, sizeof(char), len, inp);
gHashSet_insert(h, key, NULL);
new_len = MAX_KEY_LEN / 10 + rand() % 60;
}
gHashSet_print(h, stderr);
FILE *out = fopen("stat.txt", "w");
gHashSet_statistics(h, out);
fclose(out);
gHashSet_dtor(h);
}