test_kprint
This commit is contained in:
@@ -1,29 +1,11 @@
|
||||
#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();
|
||||
for(ktid id=0; id<ktid_last; id++){
|
||||
ktDescriptor d=ktDescriptor_get(id);
|
||||
kprintf("{ id:%u name:%s size:%u freeMembers:%p toString:%p }\n",
|
||||
d.id, d.name, d.size, d.freeMembers, d.toString);
|
||||
}
|
||||
kprintf("\e[97mkerep tests are starting!\n");
|
||||
optime("test_all",1,test_all());
|
||||
ktDescriptors_free();
|
||||
|
||||
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_bgGreenD|kp_fgRed|
|
||||
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_bgBlueD|kp_fgRed|
|
||||
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_bgBlack|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,' ', kp_b,1, kp_c,' ', kp_b,-1, kp_c,' ', kp_b,15, kp_c,' ',
|
||||
kp_b,4095, kp_c,' ', 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,' ', kp_b,0.0f, kp_c,' ', kp_b,1.0f, kp_c,'\n',
|
||||
kp_b, 0.00016f, kp_c,' ', 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(kp_bgBlack | kp_fg##COLOR);\
|
||||
kprint_setColor(kp_bgBlack|kp_fg##COLOR);\
|
||||
kprintf(#COLOR " ");\
|
||||
kprint_setColor(kp_bg##COLOR | kp_fgGray);\
|
||||
kprint_setColor(kp_bg##COLOR|kp_fgGray);\
|
||||
kprintf(#COLOR);\
|
||||
kprint_setColor(kp_bgBlack | kp_fgBlack);\
|
||||
kprint_setColor(kp_bgBlack|kp_fgBlack);\
|
||||
kprintf("\n");
|
||||
|
||||
void test_kprint_colors(){
|
||||
@@ -44,7 +44,5 @@ void test_kprint_colors(){
|
||||
testColor(Magenta);
|
||||
testColor(Cyan);
|
||||
testColor(White);
|
||||
kprint_setColor(kp_bgBlack | kp_fgGray);
|
||||
|
||||
kprint(kprint_fmtInt | kp_fgCyan, 8888, kprint_fmtString | kp_fgYellow, " ooo ", kprint_fmtFloat | kp_bgGreenD | kp_fgRed, 4.01, kprint_fmtString | kp_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,27 @@ 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(){
|
||||
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