diff --git a/tests/main.cpp b/tests/main.cpp index ff2a4d4..ab78183 100644 --- a/tests/main.cpp +++ b/tests/main.cpp @@ -1,14 +1,15 @@ #include "tests.h" void test_all(){ + // test_string(); + // test_safethrow(); + // test_searchtree(); test_autoarr(); - test_string(); - test_safethrow(); - test_searchtree(); - test_hashtable(); - test_dtsod(); test_autoarr2(); - test_hash_functions(); + // test_hash_functions(); + test_hashtable(); + test_hashtable2(); + //test_dtsod(); printf("\e[96m--------------------------------------\e[0m\n"); } diff --git a/tests/test_hash_functions.c b/tests/test_hash_functions.c index ae4f1ee..57c3f28 100644 --- a/tests/test_hash_functions.c +++ b/tests/test_hash_functions.c @@ -3,7 +3,7 @@ #include "../src/Autoarr/Autoarr.h" -#define SPEED_TESTS 10000 +#define SPEED_TESTS 100000 #define COLLISION_TESTS 16000 char data[]="iojihiojopijiugbjmoihftytryfdrh"; diff --git a/tests/test_hashtable2.cpp b/tests/test_hashtable2.cpp new file mode 100644 index 0000000..b06d8ec --- /dev/null +++ b/tests/test_hashtable2.cpp @@ -0,0 +1,58 @@ +#include "tests.h" +#include "../src/Hashtable2/Hashtable2.hpp" + +#define TKey char* +#define TVal uint64 +#define HT_TYPE Hashtable2 +#define HT_TYPE_NAME "Hashtable2" + +void print_hashtable(HT_TYPE* ht){ + printf("\e[94m" HT_TYPE_NAME ": " + IFWIN("%llu", "%lu") + "\n height: %u\n", + sizeof(HT_TYPE), + ht->height()); +} + +char* genkey(uint32 i){ + char* key=new char[16]; + IFMSC( + sprintf_s(key,16,"key_%u",i), + sprintf(key,"key_%u",i) + ); + return key; +} + +void fill(HT_TYPE* ht){ + //for(uint32 i=0;i<100000;i++) + // ht->add(genkey(i),Uni(UInt64,i)); +} + +TVal gett(HT_TYPE* ht){ + TVal u; + for(uint32 i=0;i<100000;i++){ + TKey key=genkey(i); + //u=ht->get(key); + delete[] key; + } + return u; +} + + +void test_hashtable2(){ + optime("test_hashtable2",1,({ + printf("\e[96m-----------[test_hashtable2]-----------\n"); +#if STORE_HASHES + HT_TYPE* ht=new HT_TYPE(); +#else + HT_TYPE* ht=new HT_TYPE(cptr_compare); +#endif + printf("\e[92m" HT_TYPE_NAME " created\n"); + print_hashtable(ht); + optime("fill",1,fill(ht)); + optime("get",1,gett(ht)); + print_hashtable(ht); + delete ht; + printf("\e[92m" HT_TYPE_NAME " deleted\n"); + })); +} diff --git a/tests/tests.h b/tests/tests.h index 6fb6543..fb0be11 100644 --- a/tests/tests.h +++ b/tests/tests.h @@ -5,14 +5,17 @@ #if __cplusplus extern "C" { #endif + +void test_string(); +void test_safethrow(); void test_searchtree(); void test_autoarr(); -void test_hashtable(); -void test_string(); -void test_dtsod(); -void test_safethrow(); void test_autoarr2(); void test_hash_functions(); +void test_hashtable(); +void test_hashtable2(); +void test_dtsod(); + #if __cplusplus } #endif \ No newline at end of file