From 1fd84c7dc70a0a6e6d8651fafa50c51dd697ae77 Mon Sep 17 00:00:00 2001 From: Benedict Date: Thu, 2 Feb 2017 00:32:26 +0100 Subject: added random stuff which hasn't beend added because yeah --- lib/util/test_hash.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 lib/util/test_hash.c (limited to 'lib/util/test_hash.c') 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"); + +} -- cgit v1.2.3-70-g09d2