Wrote tests for Toy_Table

I hope that's it, I don't wanna do that again XD
This commit is contained in:
2024-10-04 16:50:54 +10:00
parent 5cf2e70b7d
commit 196b5f86f1
6 changed files with 759 additions and 73 deletions

18
.notes/hash_generator_1.c Normal file
View File

@@ -0,0 +1,18 @@
https://www.programiz.com/c-programming/online-compiler/
#include <stdio.h>
static unsigned int hashUInt(unsigned int x) {
x = ((x >> 16) ^ x) * 0x45d9f3b;
x = ((x >> 16) ^ x) * 0x45d9f3b;
x = (x >> 16) ^ x;
return x;
}
int main() {
//print the index/hash pairs
for (unsigned int i = 0; i < 100; i++) {
printf("{%u:%u}\n", i, hashUInt(i) % 16);
}
return 0;
}

23
.notes/hash_generator_2.c Normal file
View File

@@ -0,0 +1,23 @@
https://www.programiz.com/c-programming/online-compiler/
#include <stdio.h>
static unsigned int hashUInt(unsigned int x) {
x = ((x >> 16) ^ x) * 0x45d9f3b;
x = ((x >> 16) ^ x) * 0x45d9f3b;
x = (x >> 16) ^ x;
return x;
}
int main() {
//find the first number with a specific hash, then print the c-code
for (unsigned int h = 0; h < 20; h++) {
for (unsigned int i = 0; i < 100; i++) {
if (hashUInt(i) % 32 == h) {
printf("Toy_insertTable(&table, TOY_VALUE_TO_INTEGER(%d), TOY_VALUE_TO_INTEGER(42)); //hash: %d\n", i, h);
break;
}
}
}
return 0;
}