76
This commit is contained in:
parent
38aad5c108
commit
9b055d775a
@ -1,14 +1,15 @@
|
|||||||
#include "tests.h"
|
#include "tests.h"
|
||||||
|
|
||||||
void test_all(){
|
void test_all(){
|
||||||
|
// test_string();
|
||||||
|
// test_safethrow();
|
||||||
|
// test_searchtree();
|
||||||
test_autoarr();
|
test_autoarr();
|
||||||
test_string();
|
|
||||||
test_safethrow();
|
|
||||||
test_searchtree();
|
|
||||||
test_hashtable();
|
|
||||||
test_dtsod();
|
|
||||||
test_autoarr2();
|
test_autoarr2();
|
||||||
test_hash_functions();
|
// test_hash_functions();
|
||||||
|
test_hashtable();
|
||||||
|
test_hashtable2();
|
||||||
|
//test_dtsod();
|
||||||
printf("\e[96m--------------------------------------\e[0m\n");
|
printf("\e[96m--------------------------------------\e[0m\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -3,7 +3,7 @@
|
|||||||
#include "../src/Autoarr/Autoarr.h"
|
#include "../src/Autoarr/Autoarr.h"
|
||||||
|
|
||||||
|
|
||||||
#define SPEED_TESTS 10000
|
#define SPEED_TESTS 100000
|
||||||
#define COLLISION_TESTS 16000
|
#define COLLISION_TESTS 16000
|
||||||
|
|
||||||
char data[]="iojihiojopijiugbjmoihftytryfdrh";
|
char data[]="iojihiojopijiugbjmoihftytryfdrh";
|
||||||
|
|||||||
58
tests/test_hashtable2.cpp
Normal file
58
tests/test_hashtable2.cpp
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
#include "tests.h"
|
||||||
|
#include "../src/Hashtable2/Hashtable2.hpp"
|
||||||
|
|
||||||
|
#define TKey char*
|
||||||
|
#define TVal uint64
|
||||||
|
#define HT_TYPE Hashtable2<TKey, TVal>
|
||||||
|
#define HT_TYPE_NAME "Hashtable2<char*, uint64>"
|
||||||
|
|
||||||
|
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");
|
||||||
|
}));
|
||||||
|
}
|
||||||
@ -5,14 +5,17 @@
|
|||||||
#if __cplusplus
|
#if __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
void test_string();
|
||||||
|
void test_safethrow();
|
||||||
void test_searchtree();
|
void test_searchtree();
|
||||||
void test_autoarr();
|
void test_autoarr();
|
||||||
void test_hashtable();
|
|
||||||
void test_string();
|
|
||||||
void test_dtsod();
|
|
||||||
void test_safethrow();
|
|
||||||
void test_autoarr2();
|
void test_autoarr2();
|
||||||
void test_hash_functions();
|
void test_hash_functions();
|
||||||
|
void test_hashtable();
|
||||||
|
void test_hashtable2();
|
||||||
|
void test_dtsod();
|
||||||
|
|
||||||
#if __cplusplus
|
#if __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
Loading…
Reference in New Issue
Block a user