summaryrefslogtreecommitdiff
path: root/lib/util/test_hash.c
diff options
context:
space:
mode:
authorBenedict <benedict@0xb8000.de>2017-02-02 00:32:26 +0100
committerBenedict <benedict@0xb8000.de>2017-02-21 13:00:27 +0100
commit1fd84c7dc70a0a6e6d8651fafa50c51dd697ae77 (patch)
treeaf5de3c7952e071c8e27800c41d9f945fa86c9e7 /lib/util/test_hash.c
parent9dcc7348ad53cab8fd9396699de0177bac6729d5 (diff)
added random stuff which hasn't beend added because yeah
Diffstat (limited to 'lib/util/test_hash.c')
-rw-r--r--lib/util/test_hash.c48
1 files changed, 48 insertions, 0 deletions
diff --git a/lib/util/test_hash.c b/lib/util/test_hash.c
new file mode 100644
index 0000000..19d2aae
--- /dev/null
+++ b/lib/util/test_hash.c
@@ -0,0 +1,48 @@
+#include "hashtable.h"
+#include "set.h"
+
+
+int main()
+{
+ int i;
+ struct hashtable ht;
+
+ char *msg = malloc(100);
+ memcpy(msg, "Hallo dies ist meine Message\n", 20);
+ char *key = malloc(20);
+
+ ht_init_sha1(&ht);
+ key[1] = '\n';
+ for(i=0;i<156;i++) {
+ key[0] = i;
+ msg[0] = i;
+ ht_add(&ht, msg, strlen(msg), key, strlen(key));
+ }
+
+
+ ht_delete(&ht, key, strlen(key));
+ char *ret = ht_get(&ht, key, strlen(key));
+ if(ret != NULL)
+ printf("uuh das sollte eigtl nicht mehr da sein\n");
+
+ key[0] = 'a' + 3;
+ ret = ht_get(&ht, key, strlen(key));
+ if(ret == NULL)
+ printf("did not found data\n");
+
+ printf("message is: %s\n", msg);
+ printf("got data from ht: %s\n", ret);
+
+
+ set_t t;
+
+ set_init(&t);
+ set_insert(&t, msg, strlen(msg));
+ if(set_is_in_set(&t, msg, strlen(msg)) == 1)
+ printf("im set, alles gut\n");
+
+ set_delete(&t, msg, strlen(msg));
+ if(set_is_in_set(&t, msg, strlen(msg)) == 0)
+ printf("nicht merg im set, alles gut\n");
+
+}