Add the hashtable test module.
[bertos.git] / bertos / struct / hashtable.c
index 5e4ee652076a69ae581736a147beb3e250b24735..d895fe7559255a6059c3900a816ae4f32edc0a21 100644 (file)
@@ -285,92 +285,3 @@ const void* ht_find(struct HashTable* ht, const void* key, uint8_t key_length)
 
        return *node;
 }
-
-
-#if 0
-
-#include <stdlib.h>
-
-bool ht_test(void);
-
-static const void* test_get_key(const void* ptr, uint8_t* length)
-{
-       const char* s = ptr;
-       *length = strlen(s);
-       return s;
-}
-
-#define NUM_ELEMENTS   256
-DECLARE_HASHTABLE_STATIC(test1, 256, test_get_key);
-DECLARE_HASHTABLE_INTERNALKEY_STATIC(test2, 256);
-
-static char data[NUM_ELEMENTS][10];
-static char keydomain[] = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
-
-static bool single_test(void)
-{
-       int i;
-
-       ht_init(&test1);
-       ht_init(&test2);
-
-       for (i=0;i<NUM_ELEMENTS;i++)
-       {
-               int k;
-               int klen;
-
-               do
-               {
-                       klen = (rand() % 8) + 1;
-                       for (k=0;k<klen;k++)
-                               data[i][k] = keydomain[rand() % (sizeof(keydomain)-1)];
-                       data[i][k]=0;
-               } while (ht_find_str(&test1, data[i]) != NULL);
-
-               ASSERT(ht_insert(&test1, data[i]));
-               ASSERT(ht_insert_str(&test2, data[i], data[i]));
-       }
-
-       for (i=0;i<NUM_ELEMENTS;i++)
-       {
-               char *found1, *found2;
-
-               found1 = (char*)ht_find_str(&test1, data[i]);
-               if (strcmp(found1, data[i]) != 0)
-               {
-                       ASSERT(strcmp(found1,data[i]) == 0);
-                       return false;
-               }
-
-               found2 = (char*)ht_find_str(&test2, data[i]);
-               if (strcmp(found2, data[i]) != 0)
-               {
-                       ASSERT(strcmp(found2,data[i]) == 0);
-                       return false;
-               }
-       }
-
-       return true;
-}
-
-static uint16_t rand_seeds[] = { 1, 42, 666, 0xDEAD, 0xBEEF, 0x1337, 0xB00B };
-
-bool ht_test(void)
-{
-       int i;
-
-       for (i=0;i<countof(rand_seeds);++i)
-       {
-               srand(rand_seeds[i]);
-               if (!single_test())
-               {
-                       kprintf("ht_test failed\n");
-                       return false;
-               }
-       }
-
-       kprintf("ht_test successful\n");
-       return true;
-}
-
-#endif