Merge branch 'main' into network
This commit is contained in:
@@ -1,26 +1,12 @@
|
||||
#include "tests.h"
|
||||
|
||||
void test_all(){
|
||||
test_string();
|
||||
test_safethrow();
|
||||
test_searchtree();
|
||||
test_autoarr();
|
||||
test_autoarrVsVector();
|
||||
test_hash_functions();
|
||||
test_hashtable();
|
||||
test_dtsod();
|
||||
test_rng_algorithms();
|
||||
test_kprint_colors();
|
||||
kprintf("\e[96m--------------------------------------\e[0m\n");
|
||||
}
|
||||
int main(){
|
||||
if(!setlocale(LC_ALL, "C.UTF8"))
|
||||
kprintf("\e[93msetlocale failed\n");
|
||||
ktDescriptors_beginInit();
|
||||
ktDescriptors_initKerepTypes();
|
||||
ktDescriptors_endInit();
|
||||
kprintf("\e[97mkerep tests are starting!\n");
|
||||
optime("test_all",1,test_all());
|
||||
test_all();
|
||||
ktDescriptors_free();
|
||||
kprintf("\e[0m\n");
|
||||
return 0;
|
||||
|
||||
@@ -7,34 +7,28 @@ int64 _autoarrVsVector(uint16 blockCount, uint16 blockLength){
|
||||
kprintf("\e[94mblock count: %u block length: %u count: " IFWIN("%llu", "%lu") "\n", blockCount, blockLength, (uint64)count);
|
||||
Autoarr_int64* ar=Autoarr_create(int64, blockCount, blockLength);
|
||||
std::vector<int64> vec=std::vector<int64>();
|
||||
optime("Autoarr_add", 1, ({
|
||||
for(uint32 i=0; i< count; i++)
|
||||
Autoarr_add(ar, i);
|
||||
}));
|
||||
optime("vector_push_back", 1, ({
|
||||
for(uint32 i=0; i< count; i++)
|
||||
vec.push_back(i);
|
||||
}));
|
||||
optime("Autoarr_add", count,
|
||||
Autoarr_add(ar, op_i));
|
||||
optime("vector_push_back", count,
|
||||
vec.push_back(op_i));
|
||||
int64 t=0;
|
||||
optime("Autoarr_get", 1, ({
|
||||
for(uint32 i=0; i< count; i++)
|
||||
t=Autoarr_get(ar, i);
|
||||
}));
|
||||
optime("vector_get", 1, ({
|
||||
for(uint32 i=0; i< count; i++)
|
||||
t=vec[i];
|
||||
}));
|
||||
optime("Autoarr_get", count,
|
||||
t=Autoarr_get(ar, op_i));
|
||||
optime("vector_get", count,
|
||||
t=vec[op_i]);
|
||||
Autoarr_free(ar, true);
|
||||
return t;
|
||||
}
|
||||
|
||||
void test_autoarrVsVector(){
|
||||
kprintf("\e[96m-------[test_autoarr_vs_vector]-------\n");
|
||||
_autoarrVsVector(4, 16);
|
||||
_autoarrVsVector(16, 64);
|
||||
_autoarrVsVector(32, 32);
|
||||
_autoarrVsVector(64, 64);
|
||||
_autoarrVsVector(32, 1024);
|
||||
_autoarrVsVector(256, 256);
|
||||
_autoarrVsVector(1024, 1024);
|
||||
optime(__func__, 1, ({
|
||||
kprintf("\e[96m-------[test_autoarr_vs_vector]-------\n");
|
||||
_autoarrVsVector(4, 16);
|
||||
_autoarrVsVector(16, 64);
|
||||
_autoarrVsVector(32, 32);
|
||||
_autoarrVsVector(64, 64);
|
||||
_autoarrVsVector(32, 1024);
|
||||
_autoarrVsVector(256, 256);
|
||||
_autoarrVsVector(1024, 1024);
|
||||
}));
|
||||
}
|
||||
|
||||
50
tests/test_kprint.c
Normal file
50
tests/test_kprint.c
Normal file
@@ -0,0 +1,50 @@
|
||||
#include "tests.h"
|
||||
#include "../src/kprint/kprint.h"
|
||||
|
||||
void test_kprint(){
|
||||
//int
|
||||
kprint(kp_fgCyan|
|
||||
kp_i,-8888, kp_c,' ', kp_i,0, kp_c,' ', kp_i,1234567890987654321LL,kp_s,"\n");
|
||||
//uint
|
||||
kprint(kp_fgGreen|
|
||||
kp_u|kp_post,-8888, kp_c|kp_post|kp_upper,' ', kp_u,0, kp_c,' ',
|
||||
kp_u,1234567890987654321LL, kp_c,'\n');
|
||||
//float
|
||||
kprint(kp_fgCyanD|
|
||||
kp_f,-4000.0109f, kp_c,' ', kp_f,-0.000020004f, kp_c,'\n',
|
||||
kp_f,-1.0f, kp_c,' ', kp_f,0.0f, kp_c,' ', kp_f,1.0f, kp_c,'\n',
|
||||
kp_f|kp_post,0.000020004f, kp_c,' ',
|
||||
kp_f|kp_post|kp_upper,4000.0109f, kp_c,'\n');
|
||||
//double
|
||||
kprint(kp_fgYellowD|
|
||||
kp_f,-4000.0109, kp_c,' ', kp_f,-0.000020004, kp_c,'\n',
|
||||
kp_f,-1.0, kp_c,' ', kp_f,0.0, kp_c,' ', kp_f,1.0, kp_c,'\n',
|
||||
kp_f|kp_post,0.000020004, kp_c,' ',
|
||||
kp_f|kp_post|kp_upper,4000.0109, kp_c,'\n');
|
||||
//hex
|
||||
kprint(kp_fgYellow|
|
||||
kp_h,0, kp_c,' ', kp_h,1, kp_c,' ', kp_h,-1, kp_c,' ', kp_h,15, kp_c,'\n',
|
||||
kp_h,4095, kp_c,' ', kp_h,-4095, kp_c,'\n',
|
||||
kp_h,1234567890987654321LL, kp_c,'\n', kp_h,-1234567890987654321LL, kp_c,'\n');
|
||||
kprint(
|
||||
kp_h,-1.0f, kp_c,' ', kp_h,0.0f, kp_c,' ', kp_h,1.0f, kp_c,'\n',
|
||||
kp_h, 0.00016f, kp_c,' ', kp_h,-115515.009f, kp_c,'\n');
|
||||
kprint(
|
||||
kp_h|kp_pre, 0.00016, kp_c,'\n',
|
||||
kp_h|kp_pre|kp_upper,-115515.009, kp_c,'\n');
|
||||
//bin
|
||||
kprint(kp_fgBlue|
|
||||
kp_b,0, kp_c,'\n', kp_b,1, kp_c,'\n', kp_b,-1, kp_c,'\n', kp_b,15, kp_c,'\n',
|
||||
kp_b,4095, kp_c,'\n', kp_b,-4095, kp_c,'\n',
|
||||
kp_b,1234567890987654321LL, kp_c,'\n', kp_b,-1234567890987654321LL, kp_c,'\n');
|
||||
kprint(
|
||||
kp_b,-1.0f, kp_c,'\n', kp_b,0.0f, kp_c,'\n', kp_b,1.0f, kp_c,'\n',
|
||||
kp_b, 0.00016f, kp_c,'\n', kp_b,-115515.009f, kp_c,'\n');
|
||||
kprint(
|
||||
kp_b|kp_pre, 0.00016, kp_c,'\n',
|
||||
kp_b|kp_pre|kp_upper,-115515.009, kp_c,'\n');
|
||||
//string
|
||||
kprint(kp_s|kp_fgYellow, "\n ooo \n",
|
||||
kp_s|kp_fgWhite, "gg",
|
||||
kp_fgGray|kp_bgBlack|kp_s, "\n");
|
||||
}
|
||||
@@ -5,11 +5,11 @@
|
||||
#endif
|
||||
|
||||
#define testColor(COLOR) \
|
||||
kprint_setColor(kprint_bgBlack | kprint_fg##COLOR);\
|
||||
kprint_setColor(kp_bgBlack|kp_fg##COLOR);\
|
||||
kprintf(#COLOR " ");\
|
||||
kprint_setColor(kprint_bg##COLOR | kprint_fgGray);\
|
||||
kprint_setColor(kp_bg##COLOR|kp_fgGray);\
|
||||
kprintf(#COLOR);\
|
||||
kprint_setColor(kprint_bgBlack | kprint_fgBlack);\
|
||||
kprint_setColor(kp_bgBlack|kp_fgBlack);\
|
||||
kprintf("\n");
|
||||
|
||||
void test_kprint_colors(){
|
||||
@@ -29,14 +29,14 @@ void test_kprint_colors(){
|
||||
kprintf("\n"); */
|
||||
|
||||
testColor(Black);
|
||||
testColor(DarkRed);
|
||||
testColor(DarkGreen);
|
||||
testColor(DarkYellow);
|
||||
testColor(DarkBlue);
|
||||
testColor(DarkMagenta);
|
||||
testColor(DarkCyan);
|
||||
testColor(RedD);
|
||||
testColor(GreenD);
|
||||
testColor(YellowD);
|
||||
testColor(BlueD);
|
||||
testColor(MagentaD);
|
||||
testColor(CyanD);
|
||||
testColor(Gray);
|
||||
testColor(DarkGray);
|
||||
testColor(GrayD);
|
||||
testColor(Red);
|
||||
testColor(Green);
|
||||
testColor(Yellow);
|
||||
@@ -44,7 +44,5 @@ void test_kprint_colors(){
|
||||
testColor(Magenta);
|
||||
testColor(Cyan);
|
||||
testColor(White);
|
||||
kprint_setColor(kprint_bgBlack | kprint_fgGray);
|
||||
|
||||
kprint(kprint_fmtInt | kprint_fgCyan, 8888, kprint_fmtString | kprint_fgYellow, " ooo ", kprint_fmtFloat | kprint_bgDarkGreen | kprint_fgRed, 4.01, kprint_fmtString | kprint_fgWhite, "\ngg\n");
|
||||
}
|
||||
kprint_setColor(kp_bgBlack|kp_fgGray);
|
||||
}
|
||||
|
||||
9
tests/test_type_system.c
Normal file
9
tests/test_type_system.c
Normal file
@@ -0,0 +1,9 @@
|
||||
#include "tests.h"
|
||||
|
||||
void test_type_system(){
|
||||
for(ktid id=0; id<ktid_last; id++){
|
||||
ktDescriptor d=ktDescriptor_get(id);
|
||||
kprintf("\e[37m{ id:%u name:%s size:%u freeMembers:%p toString:%p }\n",
|
||||
d.id, d.name, d.size, d.freeMembers, d.toString);
|
||||
}
|
||||
}
|
||||
@@ -13,9 +13,30 @@ void test_autoarr();
|
||||
void test_hash_functions();
|
||||
void test_hashtable();
|
||||
void test_dtsod();
|
||||
void test_kprint_colors();
|
||||
void test_autoarrVsVector();
|
||||
void test_rng_algorithms();
|
||||
void test_kprint_colors();
|
||||
void test_kprint();
|
||||
void test_type_system();
|
||||
|
||||
inline void test_all(){
|
||||
kprintf("\e[97mkerep tests are starting!\n");
|
||||
optime(__func__, 1, ({
|
||||
test_type_system();
|
||||
test_string();
|
||||
test_safethrow();
|
||||
test_searchtree();
|
||||
test_autoarr();
|
||||
test_autoarrVsVector();
|
||||
test_hash_functions();
|
||||
test_hashtable();
|
||||
test_dtsod();
|
||||
test_rng_algorithms();
|
||||
test_kprint_colors();
|
||||
test_kprint();
|
||||
kprintf("\e[96m--------------------------------------\e[0m\n");
|
||||
}));
|
||||
}
|
||||
|
||||
#define PRINT_SIZEOF(T) kprintf("\e[94m" #T " size: \e[96m" IFWIN("%llu", "%lu") "\n", sizeof(T))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user