all printf calls replaced with kprintf
This commit is contained in:
parent
c70544ff97
commit
4785023126
@ -24,7 +24,7 @@ void ____Autoarr_free_KVPair_(void* ar){
|
|||||||
}
|
}
|
||||||
|
|
||||||
void printkvp(KVPair p){
|
void printkvp(KVPair p){
|
||||||
printf("{\"%s\", ",p.key);
|
kprintf("{\"%s\", ",p.key);
|
||||||
printuni(p.value);
|
printuni(p.value);
|
||||||
printf("}");
|
kprintf("}");
|
||||||
}
|
}
|
||||||
|
|||||||
@ -9,6 +9,7 @@ extern "C" {
|
|||||||
#include "cptr.h"
|
#include "cptr.h"
|
||||||
#include "optime.h"
|
#include "optime.h"
|
||||||
#include "type_system/type_system.h"
|
#include "type_system/type_system.h"
|
||||||
|
#include "../kprint/kprintf.h"
|
||||||
|
|
||||||
#if __cplusplus
|
#if __cplusplus
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
#include "std.h"
|
#include "std.h"
|
||||||
#include "errors.h"
|
#include "errors.h"
|
||||||
#include "cptr.h"
|
#include "cptr.h"
|
||||||
|
#include "../kprint/kprintf.h"
|
||||||
|
|
||||||
char* errname(ErrorId err){
|
char* errname(ErrorId err){
|
||||||
switch(err){
|
switch(err){
|
||||||
@ -47,7 +48,7 @@ void Maybe_free(Maybe e){
|
|||||||
}
|
}
|
||||||
|
|
||||||
void printMaybe(Maybe e){
|
void printMaybe(Maybe e){
|
||||||
if(e.errmsg) printf("%s\n",e.errmsg);
|
if(e.errmsg) kprintf("%s\n",e.errmsg);
|
||||||
else printuni(e.value);
|
else printuni(e.value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -36,7 +36,7 @@ void printMaybe(Maybe e);
|
|||||||
|
|
||||||
#define __RETURN_EXCEPTION(ERRMSG) return (Maybe){.errmsg=ERRMSG, .value=UniNull}
|
#define __RETURN_EXCEPTION(ERRMSG) return (Maybe){.errmsg=ERRMSG, .value=UniNull}
|
||||||
|
|
||||||
#define __EXIT(ERRMSG) ({ printf("\e[91m%s\e[0m \n", ERRMSG); free(ERRMSG); exit(128); })
|
#define __EXIT(ERRMSG) ({ kprintf("\e[91m%s\e[0m \n", ERRMSG); free(ERRMSG); exit(128); })
|
||||||
|
|
||||||
char* __doNothing(char* a);
|
char* __doNothing(char* a);
|
||||||
char* __unknownErr( );
|
char* __unknownErr( );
|
||||||
|
|||||||
@ -11,7 +11,7 @@
|
|||||||
(codeblock);\
|
(codeblock);\
|
||||||
clock_gettime(CLOCK_REALTIME, &stop);\
|
clock_gettime(CLOCK_REALTIME, &stop);\
|
||||||
double t=(double)(stop.tv_sec-start.tv_sec+(double)(stop.tv_nsec-start.tv_nsec)/1000000000)/repeats;\
|
double t=(double)(stop.tv_sec-start.tv_sec+(double)(stop.tv_nsec-start.tv_nsec)/1000000000)/repeats;\
|
||||||
printf("\e[93moperation \e[94m%s\e[93m lasted \e[94m%lf \e[93mseconds\n",opname,t);\
|
kprintf("\e[93moperation \e[94m%s\e[93m lasted \e[94m%lf \e[93mseconds\n",opname,t);\
|
||||||
})
|
})
|
||||||
#else // standard low precision clock
|
#else // standard low precision clock
|
||||||
#define optime(opname,repeats,codeblock) ({\
|
#define optime(opname,repeats,codeblock) ({\
|
||||||
@ -20,6 +20,6 @@
|
|||||||
(codeblock);\
|
(codeblock);\
|
||||||
clock_t stop=clock();\
|
clock_t stop=clock();\
|
||||||
double t=(double)(stop-start)/CLOCKS_PER_SEC/repeats;\
|
double t=(double)(stop-start)/CLOCKS_PER_SEC/repeats;\
|
||||||
printf("\e[93moperation \e[94m%s\e[93m lasted \e[94m%lf \e[93mseconds\n",opname,t);\
|
kprintf("\e[93moperation \e[94m%s\e[93m lasted \e[94m%lf \e[93mseconds\n",opname,t);\
|
||||||
})
|
})
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@ -24,7 +24,7 @@ typedef uint64_t uint64;
|
|||||||
typedef float float32;
|
typedef float float32;
|
||||||
typedef double float64;
|
typedef double float64;
|
||||||
|
|
||||||
#define dbg(N) printf("\e[95m%d\n",N)
|
#define dbg(N) kprintf("\e[95m%d\n",N)
|
||||||
|
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
#pragma comment(lib, "mincore_downlevel.lib") // Support OS older than SDK
|
#pragma comment(lib, "mincore_downlevel.lib") // Support OS older than SDK
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
#include "base_toString.h"
|
#include "base_toString.h"
|
||||||
#include "../cptr.h"
|
#include "../base.h"
|
||||||
#include "../../kprint/kprint_format.h"
|
#include "../../kprint/kprint_format.h"
|
||||||
|
|
||||||
char* __toString_char(void* c, uint32 fmt) {
|
char* __toString_char(void* c, uint32 fmt) {
|
||||||
@ -133,7 +133,7 @@ char* toString_hex(void* _bytes, uint32 size, bool withPrefix, bool uppercase){
|
|||||||
case kprint_fmtHex:\
|
case kprint_fmtHex:\
|
||||||
return toString_hex(_n, BITS/8, kprint_format_withPrefix(f), kprint_format_uppercase(f));\
|
return toString_hex(_n, BITS/8, kprint_format_withPrefix(f), kprint_format_uppercase(f));\
|
||||||
default:\
|
default:\
|
||||||
printf("\n%u\n", kprint_format_dataFormat(f));\
|
kprintf("\n%u\n", kprint_format_dataFormat(f));\
|
||||||
throw(ERR_FORMAT);\
|
throw(ERR_FORMAT);\
|
||||||
return NULL;\
|
return NULL;\
|
||||||
}\
|
}\
|
||||||
@ -153,7 +153,7 @@ __toString_int_def(64)
|
|||||||
case kprint_fmtHex:\
|
case kprint_fmtHex:\
|
||||||
return toString_hex(_n, BITS/8, kprint_format_withPrefix(f), kprint_format_uppercase(f));\
|
return toString_hex(_n, BITS/8, kprint_format_withPrefix(f), kprint_format_uppercase(f));\
|
||||||
default:\
|
default:\
|
||||||
printf("\n%u\n", kprint_format_dataFormat(f));\
|
kprintf("\n%u\n", kprint_format_dataFormat(f));\
|
||||||
throw(ERR_FORMAT);\
|
throw(ERR_FORMAT);\
|
||||||
return NULL;\
|
return NULL;\
|
||||||
}\
|
}\
|
||||||
@ -173,7 +173,7 @@ __toString_uint_def(64)
|
|||||||
case kprint_fmtHex:\
|
case kprint_fmtHex:\
|
||||||
return toString_hex(_n, BITS/8, kprint_format_withPrefix(f), kprint_format_uppercase(f));\
|
return toString_hex(_n, BITS/8, kprint_format_withPrefix(f), kprint_format_uppercase(f));\
|
||||||
default:\
|
default:\
|
||||||
printf("\n%u\n", kprint_format_dataFormat(f));\
|
kprintf("\n%u\n", kprint_format_dataFormat(f));\
|
||||||
throw(ERR_FORMAT);\
|
throw(ERR_FORMAT);\
|
||||||
return NULL;\
|
return NULL;\
|
||||||
}\
|
}\
|
||||||
|
|||||||
@ -28,8 +28,8 @@ char* __toString_float32(void* n, uint32 fmt);
|
|||||||
char* __toString_float64(void* n, uint32 fmt);
|
char* __toString_float64(void* n, uint32 fmt);
|
||||||
|
|
||||||
// universal functions
|
// universal functions
|
||||||
char* toString_bin(char* bytes, uint32 size, bool withPrefix);
|
char* toString_bin(void* bytes, uint32 size, bool withPrefix);
|
||||||
char* toString_hex(char* bytes, uint32 size, bool withPrefix, bool uppercase);
|
char* toString_hex(void* bytes, uint32 size, bool withPrefix, bool uppercase);
|
||||||
|
|
||||||
#if __cplusplus
|
#if __cplusplus
|
||||||
}
|
}
|
||||||
|
|||||||
@ -46,7 +46,7 @@ typedef enum{
|
|||||||
ktDescriptorsState initState=NotInitialized;
|
ktDescriptorsState initState=NotInitialized;
|
||||||
|
|
||||||
void ktDescriptors_beginInit(){
|
void ktDescriptors_beginInit(){
|
||||||
printf("\e[94mtype descriptors initializing...\n");
|
kprintf("\e[94mtype descriptors initializing...\n");
|
||||||
__ktDescriptors=Autoarr_create(ktDescriptor, 256, 256);
|
__ktDescriptors=Autoarr_create(ktDescriptor, 256, 256);
|
||||||
if(__ktDescriptors==NULL) throw(ERR_NULLPTR);
|
if(__ktDescriptors==NULL) throw(ERR_NULLPTR);
|
||||||
}
|
}
|
||||||
@ -55,7 +55,7 @@ void ktDescriptors_endInit(){
|
|||||||
typeDescriptors=Autoarr_toArray(__ktDescriptors);
|
typeDescriptors=Autoarr_toArray(__ktDescriptors);
|
||||||
Autoarr_free(__ktDescriptors,true);
|
Autoarr_free(__ktDescriptors,true);
|
||||||
if(typeDescriptors==NULL) throw(ERR_NULLPTR);
|
if(typeDescriptors==NULL) throw(ERR_NULLPTR);
|
||||||
printf("\e[92minitialized %u type descriptors\n", ktId_last);
|
kprintf("\e[92minitialized %u type descriptors\n", ktId_last);
|
||||||
}
|
}
|
||||||
|
|
||||||
void __kt_register(char* name, int16 size, void (*freeMembers)(void*), char* (*toString)(void*, uint32)){
|
void __kt_register(char* name, int16 size, void (*freeMembers)(void*), char* (*toString)(void*, uint32)){
|
||||||
@ -71,7 +71,7 @@ void __kt_register(char* name, int16 size, void (*freeMembers)(void*), char* (*t
|
|||||||
|
|
||||||
ktDescriptor ktDescriptor_get(ktId id){
|
ktDescriptor ktDescriptor_get(ktId id){
|
||||||
if(id>ktId_last) {
|
if(id>ktId_last) {
|
||||||
printf("\ntype id: %u\n",id);
|
kprintf("\ntype id: %u\n",id);
|
||||||
throw("invalid type id");
|
throw("invalid type id");
|
||||||
}
|
}
|
||||||
return typeDescriptors[id];
|
return typeDescriptors[id];
|
||||||
|
|||||||
@ -1,3 +1,6 @@
|
|||||||
|
# kprintf
|
||||||
|
It is just my variant of printf.
|
||||||
|
|
||||||
# kprint
|
# kprint
|
||||||
I don't really like printf function (and its variants), so i made safer and more convinient replacement.
|
I don't really like printf function (and its variants), so i made safer and more convinient replacement.
|
||||||
|
|
||||||
|
|||||||
@ -1,6 +1,5 @@
|
|||||||
#include "../String/StringBuilder.h"
|
#include "../String/StringBuilder.h"
|
||||||
#include "kprint.h"
|
#include "kprint.h"
|
||||||
#include "../base/type_system/base_toString.h"
|
|
||||||
|
|
||||||
ktId __typeFromFormat(kprint_format f){
|
ktId __typeFromFormat(kprint_format f){
|
||||||
ktId typeId=kprint_format_ktId(f);
|
ktId typeId=kprint_format_ktId(f);
|
||||||
@ -78,7 +77,7 @@ void __kprint(uint8 n, kprint_format* formats, __kprint_value_union* objects){
|
|||||||
#define FOREGROUND_YELLOW FOREGROUND_GREEN | FOREGROUND_RED
|
#define FOREGROUND_YELLOW FOREGROUND_GREEN | FOREGROUND_RED
|
||||||
|
|
||||||
DWORD kprint_fgColor_toWin(kprint_fgColor f){
|
DWORD kprint_fgColor_toWin(kprint_fgColor f){
|
||||||
//printf("fg: %x\n", f);
|
//kprintf("fg: %x\n", f);
|
||||||
switch(f){
|
switch(f){
|
||||||
case kprint_fgBlack: return 0;
|
case kprint_fgBlack: return 0;
|
||||||
case kprint_fgDarkRed: return FOREGROUND_RED;
|
case kprint_fgDarkRed: return FOREGROUND_RED;
|
||||||
@ -101,7 +100,7 @@ DWORD kprint_fgColor_toWin(kprint_fgColor f){
|
|||||||
}
|
}
|
||||||
|
|
||||||
DWORD kprint_bgColor_toWin(kprint_bgColor f){
|
DWORD kprint_bgColor_toWin(kprint_bgColor f){
|
||||||
//printf("bg: %x\n", f);
|
//kprintf("bg: %x\n", f);
|
||||||
switch(f){
|
switch(f){
|
||||||
case kprint_bgBlack: return 0;
|
case kprint_bgBlack: return 0;
|
||||||
case kprint_bgDarkRed: return BACKGROUND_RED;
|
case kprint_bgDarkRed: return BACKGROUND_RED;
|
||||||
@ -140,13 +139,13 @@ void kprint_setColor(kprint_format f){
|
|||||||
uint8 fg=(f&0x0f000000)>>24;
|
uint8 fg=(f&0x0f000000)>>24;
|
||||||
if(fg<8) fg+=30;
|
if(fg<8) fg+=30;
|
||||||
else fg+=90-8;
|
else fg+=90-8;
|
||||||
printf("\e[%um", fg);
|
kprintf("\e[%um", fg);
|
||||||
}
|
}
|
||||||
if(kprint_format_bgColorChanged(f)){
|
if(kprint_format_bgColorChanged(f)){
|
||||||
uint8 bg=(f&0x00f00000)>>20;
|
uint8 bg=(f&0x00f00000)>>20;
|
||||||
if(bg<8) bg+=40;
|
if(bg<8) bg+=40;
|
||||||
else bg+=100-8;
|
else bg+=100-8;
|
||||||
printf("\e[%um", bg);
|
kprintf("\e[%um", bg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -167,59 +166,3 @@ void kprint_setColor(kprint_format f){
|
|||||||
StringBuilder_append_char(strb, ' ');
|
StringBuilder_append_char(strb, ' ');
|
||||||
StringBuilder_append_char(strb, ']');
|
StringBuilder_append_char(strb, ']');
|
||||||
} */
|
} */
|
||||||
|
|
||||||
void kprintf(char* format, ...){
|
|
||||||
va_list vl;
|
|
||||||
va_start(vl, format);
|
|
||||||
char c;
|
|
||||||
while((c=*format++)){
|
|
||||||
if(c=='%'){
|
|
||||||
c=*format++;
|
|
||||||
switch (c) {
|
|
||||||
case 'u':
|
|
||||||
toString_uint(va_arg(vl, uint64),0,0);
|
|
||||||
break;
|
|
||||||
case 'i':
|
|
||||||
toString_int(va_arg(vl, uint64));
|
|
||||||
break;
|
|
||||||
case 'f':
|
|
||||||
toString_float(va_arg(vl, float64),0,0);
|
|
||||||
break;
|
|
||||||
/* case 'l':
|
|
||||||
c=*format++;
|
|
||||||
switch (c) {
|
|
||||||
case 'u':
|
|
||||||
toString_uint(va_arg(vl, uint64),0,0);
|
|
||||||
break;
|
|
||||||
case 'i':
|
|
||||||
toString_int(va_arg(vl, uint64));
|
|
||||||
break;
|
|
||||||
case 'f':
|
|
||||||
toString_float(va_arg(vl, float64),0,0);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
throw(ERR_FORMAT);
|
|
||||||
}
|
|
||||||
break; */
|
|
||||||
case 'p':
|
|
||||||
case 'x':
|
|
||||||
uint64 px=va_arg(vl, uint64);
|
|
||||||
toString_hex(&px,sizeof(px),1,0);
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
throw(ERR_FORMAT);
|
|
||||||
}
|
|
||||||
} else if(c=='\e'){
|
|
||||||
IFWIN(
|
|
||||||
({
|
|
||||||
|
|
||||||
}),
|
|
||||||
putc(c,stdout);
|
|
||||||
)
|
|
||||||
} else {
|
|
||||||
putc(c,stdout);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
va_end(vl);
|
|
||||||
}
|
|
||||||
|
|||||||
@ -65,9 +65,6 @@ Maybe __kfprint(FILE* fd, uint8 n, kprint_format* formats, __kprint_value_union*
|
|||||||
void __kprint(uint8 n, kprint_format* formats, __kprint_value_union* objects);
|
void __kprint(uint8 n, kprint_format* formats, __kprint_value_union* objects);
|
||||||
#define kprint(ARGS...) __kprint(count_args(ARGS), __kprint_argsToArrs(count_args(ARGS),ARGS, __32zeroes))
|
#define kprint(ARGS...) __kprint(count_args(ARGS), __kprint_argsToArrs(count_args(ARGS),ARGS, __32zeroes))
|
||||||
|
|
||||||
// cross-platform printf analog
|
|
||||||
void kprintf(char* format, ...);
|
|
||||||
|
|
||||||
// can take (bgColor | fgColor)
|
// can take (bgColor | fgColor)
|
||||||
void kprint_setColor(kprint_format f);
|
void kprint_setColor(kprint_format f);
|
||||||
|
|
||||||
|
|||||||
73
src/kprint/kprintf.c
Normal file
73
src/kprint/kprintf.c
Normal file
@ -0,0 +1,73 @@
|
|||||||
|
#include "kprintf.h"
|
||||||
|
#include "../base/base.h"
|
||||||
|
#include "../base/type_system/base_toString.h"
|
||||||
|
|
||||||
|
void kprintf(const char* format, ...){
|
||||||
|
va_list vl;
|
||||||
|
va_start(vl, format);
|
||||||
|
char c;
|
||||||
|
while((c=*format++)){
|
||||||
|
if(c=='%'){
|
||||||
|
char* argstr=NULL;
|
||||||
|
c=*format++;
|
||||||
|
format_escape_seq:
|
||||||
|
switch (c) {
|
||||||
|
case 'u':
|
||||||
|
argstr=toString_uint(va_arg(vl, uint64),0,0);
|
||||||
|
break;
|
||||||
|
case 'i':
|
||||||
|
argstr=toString_int(va_arg(vl, uint64));
|
||||||
|
break;
|
||||||
|
case 'f':
|
||||||
|
argstr=toString_float(va_arg(vl, float64),0,0);
|
||||||
|
break;
|
||||||
|
case 'l':
|
||||||
|
c=*format++;
|
||||||
|
goto format_escape_seq;
|
||||||
|
// switch (c) {
|
||||||
|
// case 'u':
|
||||||
|
// argstr=toString_uint(va_arg(vl, uint64),0,0);
|
||||||
|
// break;
|
||||||
|
// case 'i':
|
||||||
|
// argstr=toString_int(va_arg(vl, uint64));
|
||||||
|
// break;
|
||||||
|
// case 'f':
|
||||||
|
// argstr=toString_float(va_arg(vl, float64),0,0);
|
||||||
|
// break;
|
||||||
|
// default:
|
||||||
|
// throw(ERR_FORMAT);
|
||||||
|
// }
|
||||||
|
// break;
|
||||||
|
case 'p':
|
||||||
|
case 'x':
|
||||||
|
uint64 px=va_arg(vl, uint64);
|
||||||
|
argstr=toString_hex(&px,sizeof(px),1,0);
|
||||||
|
break;
|
||||||
|
case 's':
|
||||||
|
fputs(va_arg(vl,char*), stdout);
|
||||||
|
break;
|
||||||
|
case 'c':
|
||||||
|
argstr=malloc(2);
|
||||||
|
argstr[0]=va_arg(vl,char);
|
||||||
|
argstr[1]=0;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
throw(ERR_FORMAT);
|
||||||
|
}
|
||||||
|
if(argstr){
|
||||||
|
fputs(argstr, stdout);
|
||||||
|
free(argstr);
|
||||||
|
}
|
||||||
|
} else if(c=='\e'){
|
||||||
|
IFWIN(
|
||||||
|
({
|
||||||
|
|
||||||
|
}),
|
||||||
|
putc(c,stdout);
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
putc(c,stdout);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
va_end(vl);
|
||||||
|
}
|
||||||
12
src/kprint/kprintf.h
Normal file
12
src/kprint/kprintf.h
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#if __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// cross-platform kprintf analog
|
||||||
|
void kprintf(const char* format, ...);
|
||||||
|
|
||||||
|
#if __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
@ -11,18 +11,18 @@ void test_all(){
|
|||||||
test_dtsod();
|
test_dtsod();
|
||||||
test_rng_algorithms();
|
test_rng_algorithms();
|
||||||
test_kprint_colors();
|
test_kprint_colors();
|
||||||
printf("\e[96m--------------------------------------\e[0m\n");
|
kprintf("\e[96m--------------------------------------\e[0m\n");
|
||||||
}
|
}
|
||||||
int main(){
|
int main(){
|
||||||
setlocale(LC_ALL, "en-US.Unicode");
|
setlocale(LC_ALL, "en-US.Unicode");
|
||||||
ktDescriptors_beginInit();
|
ktDescriptors_beginInit();
|
||||||
ktDescriptors_initKerepTypes();
|
ktDescriptors_initKerepTypes();
|
||||||
ktDescriptors_endInit();
|
ktDescriptors_endInit();
|
||||||
printf("\e[97mkerep tests are starting!\n");
|
kprintf("\e[97mkerep tests are starting!\n");
|
||||||
// optime("test_all",1,test_all());
|
// optime("test_all",1,test_all());
|
||||||
test_rng_algorithms();
|
test_rng_algorithms();
|
||||||
test_kprint_colors();
|
test_kprint_colors();
|
||||||
ktDescriptors_free();
|
ktDescriptors_free();
|
||||||
printf("\e[0m\n");
|
kprintf("\e[0m\n");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
int64 _autoarrVsVector(uint16 blockCount, uint16 blockLength){
|
int64 _autoarrVsVector(uint16 blockCount, uint16 blockLength){
|
||||||
uint32 count=blockLength*blockCount;
|
uint32 count=blockLength*blockCount;
|
||||||
printf("\e[94mblock count: %u block length: %u count: " IFWIN("%llu", "%lu") "\n", blockCount, blockLength, (uint64)count);
|
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);
|
Autoarr_int64* ar=Autoarr_create(int64, blockCount, blockLength);
|
||||||
std::vector<int64> vec=std::vector<int64>();
|
std::vector<int64> vec=std::vector<int64>();
|
||||||
optime("Autoarr_add", 1, ({
|
optime("Autoarr_add", 1, ({
|
||||||
@ -29,7 +29,7 @@ int64 _autoarrVsVector(uint16 blockCount, uint16 blockLength){
|
|||||||
}
|
}
|
||||||
|
|
||||||
void test_autoarrVsVector(){
|
void test_autoarrVsVector(){
|
||||||
printf("\e[96m-------[test_autoarr_vs_vector]-------\n");
|
kprintf("\e[96m-------[test_autoarr_vs_vector]-------\n");
|
||||||
_autoarrVsVector(4, 16);
|
_autoarrVsVector(4, 16);
|
||||||
_autoarrVsVector(16, 64);
|
_autoarrVsVector(16, 64);
|
||||||
_autoarrVsVector(32, 32);
|
_autoarrVsVector(32, 32);
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
#include "../src/Autoarr/Autoarr.h"
|
#include "../src/Autoarr/Autoarr.h"
|
||||||
|
|
||||||
static void printautoarr(Autoarr(uint16)* ar){
|
static void printautoarr(Autoarr(uint16)* ar){
|
||||||
printf("\e[94mAutoarr(uint16): "
|
kprintf("\e[94mAutoarr(uint16): "
|
||||||
IFWIN("%llu", "%lu")
|
IFWIN("%llu", "%lu")
|
||||||
"\n max_blocks_count: %u\n"
|
"\n max_blocks_count: %u\n"
|
||||||
" blocks_count: %u\n"
|
" blocks_count: %u\n"
|
||||||
@ -29,25 +29,25 @@ static void resetar(Autoarr(uint16)* ar){
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void printallval(Autoarr(uint16)* ar){
|
static void printallval(Autoarr(uint16)* ar){
|
||||||
printf("\e[90m");
|
kprintf("\e[90m");
|
||||||
for (uint16 i=0;i<Autoarr_length(ar);i++)
|
for (uint16 i=0;i<Autoarr_length(ar);i++)
|
||||||
printf("%u ",Autoarr_get(ar,i));
|
kprintf("%u ",Autoarr_get(ar,i));
|
||||||
printf("\n");
|
kprintf("\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
void test_autoarr(){
|
void test_autoarr(){
|
||||||
optime("test_autoarr",1,({
|
optime("test_autoarr",1,({
|
||||||
printf("\e[96m------------[test_autoarr]------------\n");
|
kprintf("\e[96m------------[test_autoarr]------------\n");
|
||||||
Autoarr(uint16)* ar=Autoarr_create(uint16,10,16);
|
Autoarr(uint16)* ar=Autoarr_create(uint16,10,16);
|
||||||
printf("\e[92mautoarr created\n");
|
kprintf("\e[92mautoarr created\n");
|
||||||
fillar(ar);
|
fillar(ar);
|
||||||
printf("\e[92mautoarr filled up\n");
|
kprintf("\e[92mautoarr filled up\n");
|
||||||
printautoarr(ar);
|
printautoarr(ar);
|
||||||
printallval(ar);
|
printallval(ar);
|
||||||
resetar(ar);
|
resetar(ar);
|
||||||
printf("\e[92mautoarr values reset\n");
|
kprintf("\e[92mautoarr values reset\n");
|
||||||
printallval(ar);
|
printallval(ar);
|
||||||
Autoarr_free(ar, true);
|
Autoarr_free(ar, true);
|
||||||
printf("\e[92mautoarr deleted\n");
|
kprintf("\e[92mautoarr deleted\n");
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|||||||
@ -15,26 +15,26 @@ const char text[]=
|
|||||||
"h: { };";
|
"h: { };";
|
||||||
|
|
||||||
void print_dtsod(Hashtable* dtsod){
|
void print_dtsod(Hashtable* dtsod){
|
||||||
printf("\e[92m");
|
kprintf("\e[92m");
|
||||||
Hashtable_foreach(dtsod, p,({
|
Hashtable_foreach(dtsod, p,({
|
||||||
printkvp(p);
|
printkvp(p);
|
||||||
if(p.value.typeId==ktId_HashtablePtr){
|
if(p.value.typeId==ktId_HashtablePtr){
|
||||||
printf(": {\n");
|
kprintf(": {\n");
|
||||||
Hashtable* sub=p.value.VoidPtr;
|
Hashtable* sub=p.value.VoidPtr;
|
||||||
Hashtable_foreach(sub, _p,({
|
Hashtable_foreach(sub, _p,({
|
||||||
printf(" ");
|
kprintf(" ");
|
||||||
printkvp(_p);
|
printkvp(_p);
|
||||||
printf("\n");
|
kprintf("\n");
|
||||||
}));
|
}));
|
||||||
printf("}");
|
kprintf("}");
|
||||||
}
|
}
|
||||||
printf("\n");
|
kprintf("\n");
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
void test_dtsod(){
|
void test_dtsod(){
|
||||||
optime(__func__,1,({
|
optime(__func__,1,({
|
||||||
printf("\e[96m-------------[test_dtsod]-------------\n");
|
kprintf("\e[96m-------------[test_dtsod]-------------\n");
|
||||||
Hashtable* dtsod;
|
Hashtable* dtsod;
|
||||||
char* s;
|
char* s;
|
||||||
|
|
||||||
@ -49,7 +49,7 @@ void test_dtsod(){
|
|||||||
s=r.value.VoidPtr;
|
s=r.value.VoidPtr;
|
||||||
}));
|
}));
|
||||||
DtsodV24_free(dtsod);
|
DtsodV24_free(dtsod);
|
||||||
printf("\e[92m%s",s);
|
kprintf("\e[92m%s",s);
|
||||||
|
|
||||||
optime("reserialize",10,({
|
optime("reserialize",10,({
|
||||||
tryLast(DtsodV24_deserialize(s),r)
|
tryLast(DtsodV24_deserialize(s),r)
|
||||||
|
|||||||
@ -9,13 +9,13 @@
|
|||||||
char data[]="iojihiojopijiugbjmoihftytryfdrh";
|
char data[]="iojihiojopijiugbjmoihftytryfdrh";
|
||||||
|
|
||||||
#define test_hashfunc(hasht, hashf)({\
|
#define test_hashfunc(hasht, hashf)({\
|
||||||
printf("\e[94mfunction: \e[92m" #hashf "\n");\
|
kprintf("\e[94mfunction: \e[92m" #hashf "\n");\
|
||||||
hasht h=0;\
|
hasht h=0;\
|
||||||
optime("speed test", 1, ({\
|
optime("speed test", 1, ({\
|
||||||
for(uint32 i=0; i<SPEED_TESTS; i++)\
|
for(uint32 i=0; i<SPEED_TESTS; i++)\
|
||||||
h=hashf(h, data, sizeof(data));\
|
h=hashf(h, data, sizeof(data));\
|
||||||
}));\
|
}));\
|
||||||
/*printf("\e[94mhash of \"\e[90m%s\e[94m\": \e[92m%x\n",data, h);*/\
|
/*kprintf("\e[94mhash of \"\e[90m%s\e[94m\": \e[92m%x\n",data, h);*/\
|
||||||
Autoarr(hasht)* hashes=Autoarr_create(hasht,512,32768);\
|
Autoarr(hasht)* hashes=Autoarr_create(hasht,512,32768);\
|
||||||
optime("collision test",1,({\
|
optime("collision test",1,({\
|
||||||
uint32 collisions=0;\
|
uint32 collisions=0;\
|
||||||
@ -31,15 +31,15 @@ char data[]="iojihiojopijiugbjmoihftytryfdrh";
|
|||||||
if(col) collisions++;\
|
if(col) collisions++;\
|
||||||
else Autoarr_add(hashes,h);\
|
else Autoarr_add(hashes,h);\
|
||||||
}\
|
}\
|
||||||
printf("\e[93m%u \e[94mcollisions detected in %u hashes\n", collisions, COLLISION_TESTS);\
|
kprintf("\e[93m%u \e[94mcollisions detected in %u hashes\n", collisions, COLLISION_TESTS);\
|
||||||
}));\
|
}));\
|
||||||
Autoarr_free(hashes, true);\
|
Autoarr_free(hashes, true);\
|
||||||
printf("\e[96m--------------------------------------\n");\
|
kprintf("\e[96m--------------------------------------\n");\
|
||||||
})
|
})
|
||||||
|
|
||||||
void test_hash_functions(){
|
void test_hash_functions(){
|
||||||
optime("test_hash_functions",1,({
|
optime("test_hash_functions",1,({
|
||||||
printf("\e[96m--------[test_hash_functions]---------\n");
|
kprintf("\e[96m--------[test_hash_functions]---------\n");
|
||||||
test_hashfunc(uint32, hash_crc32);
|
test_hashfunc(uint32, hash_crc32);
|
||||||
test_hashfunc(uint32, hash_sdbm32);
|
test_hashfunc(uint32, hash_sdbm32);
|
||||||
}));
|
}));
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
#include "../src/Hashtable/Hashtable.h"
|
#include "../src/Hashtable/Hashtable.h"
|
||||||
|
|
||||||
void print_hashtable(Hashtable* ht){
|
void print_hashtable(Hashtable* ht){
|
||||||
printf("\e[94mHashtable: "
|
kprintf("\e[94mHashtable: "
|
||||||
IFWIN("%llu", "%lu")
|
IFWIN("%llu", "%lu")
|
||||||
"\n hein: %u\n"
|
"\n hein: %u\n"
|
||||||
" height: %u\n"
|
" height: %u\n"
|
||||||
@ -14,7 +14,7 @@ void print_hashtable(Hashtable* ht){
|
|||||||
}
|
}
|
||||||
|
|
||||||
void printrowgraph(Hashtable* ht){
|
void printrowgraph(Hashtable* ht){
|
||||||
printf("\e[94mrow length graph:\n");
|
kprintf("\e[94mrow length graph:\n");
|
||||||
uint16 lgs_l=1000;
|
uint16 lgs_l=1000;
|
||||||
uint32 lgs[lgs_l];
|
uint32 lgs[lgs_l];
|
||||||
for(uint32 i=0; i<lgs_l; i++)
|
for(uint32 i=0; i<lgs_l; i++)
|
||||||
@ -29,7 +29,7 @@ void printrowgraph(Hashtable* ht){
|
|||||||
char* str0=char_multiply(' ',i>=100?0:(i>=10?1:2));
|
char* str0=char_multiply(' ',i>=100?0:(i>=10?1:2));
|
||||||
char* str1=char_multiply(' ',lgs[i]>=100?0:(lgs[i]>=10?1:2));
|
char* str1=char_multiply(' ',lgs[i]>=100?0:(lgs[i]>=10?1:2));
|
||||||
char* str2=char_multiply('#',lgs[i]/100);
|
char* str2=char_multiply('#',lgs[i]/100);
|
||||||
printf("\e[94m length: \e[96m%u %s \e[94mfrequency: \e[96m%u %s \e[90m%s\n",i,str0,lgs[i],str1,str2);
|
kprintf("\e[94m length: \e[96m%u %s \e[94mfrequency: \e[96m%u %s \e[90m%s\n",i,str0,lgs[i],str1,str2);
|
||||||
free(str0);
|
free(str0);
|
||||||
free(str1);
|
free(str1);
|
||||||
free(str2);
|
free(str2);
|
||||||
@ -63,15 +63,15 @@ Unitype gett(Hashtable* ht){
|
|||||||
|
|
||||||
void test_hashtable(){
|
void test_hashtable(){
|
||||||
optime("test_hashtable",1,({
|
optime("test_hashtable",1,({
|
||||||
printf("\e[96m-----------[test_hashtable]-----------\n");
|
kprintf("\e[96m-----------[test_hashtable]-----------\n");
|
||||||
Hashtable* ht=Hashtable_create();
|
Hashtable* ht=Hashtable_create();
|
||||||
printf("\e[92mhashtable created\n");
|
kprintf("\e[92mhashtable created\n");
|
||||||
print_hashtable(ht);
|
print_hashtable(ht);
|
||||||
optime("fill",1,fill(ht));
|
optime("fill",1,fill(ht));
|
||||||
optime("get",1,gett(ht));
|
optime("get",1,gett(ht));
|
||||||
printrowgraph(ht);
|
printrowgraph(ht);
|
||||||
print_hashtable(ht);
|
print_hashtable(ht);
|
||||||
Hashtable_free(ht);
|
Hashtable_free(ht);
|
||||||
printf("\e[92mhashtable freed\n");
|
kprintf("\e[92mhashtable freed\n");
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|||||||
@ -6,11 +6,11 @@
|
|||||||
|
|
||||||
#define testColor(COLOR) \
|
#define testColor(COLOR) \
|
||||||
kprint_setColor(kprint_bgBlack | kprint_fg##COLOR);\
|
kprint_setColor(kprint_bgBlack | kprint_fg##COLOR);\
|
||||||
printf(#COLOR " ");\
|
kprintf(#COLOR " ");\
|
||||||
kprint_setColor(kprint_bg##COLOR | kprint_fgGray);\
|
kprint_setColor(kprint_bg##COLOR | kprint_fgGray);\
|
||||||
printf(#COLOR);\
|
kprintf(#COLOR);\
|
||||||
kprint_setColor(kprint_bgBlack | kprint_fgBlack);\
|
kprint_setColor(kprint_bgBlack | kprint_fgBlack);\
|
||||||
printf("\n");
|
kprintf("\n");
|
||||||
|
|
||||||
void test_kprint_colors(){
|
void test_kprint_colors(){
|
||||||
/* IFWIN(
|
/* IFWIN(
|
||||||
@ -18,15 +18,15 @@ void test_kprint_colors(){
|
|||||||
HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
|
HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
|
||||||
for(uint8 col=0; col<255; col++){
|
for(uint8 col=0; col<255; col++){
|
||||||
SetConsoleTextAttribute(hConsole, col);
|
SetConsoleTextAttribute(hConsole, col);
|
||||||
printf("%u ",col);
|
kprintf("%u ",col);
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
({
|
({
|
||||||
for(uint8 col=0; col<255; col++)
|
for(uint8 col=0; col<255; col++)
|
||||||
printf("\e[%um%u ", col, col);
|
kprintf("\e[%um%u ", col, col);
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
printf("\n"); */
|
kprintf("\n"); */
|
||||||
|
|
||||||
testColor(Black);
|
testColor(Black);
|
||||||
testColor(DarkRed);
|
testColor(DarkRed);
|
||||||
|
|||||||
@ -10,5 +10,5 @@ EXPORT void CALL test_marshalling(char* text, KVPair** kptr){
|
|||||||
}
|
}
|
||||||
|
|
||||||
EXPORT void CALL pinvoke_print(char* msg) {
|
EXPORT void CALL pinvoke_print(char* msg) {
|
||||||
printf("printed from unmanaged code: %s\n", msg);
|
kprintf("printed from unmanaged code: %s\n", msg);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -3,25 +3,25 @@
|
|||||||
|
|
||||||
|
|
||||||
#define test_alg(ALG, VALUE_SIZE, EXPECTED_FROM_ZERO){\
|
#define test_alg(ALG, VALUE_SIZE, EXPECTED_FROM_ZERO){\
|
||||||
printf("\e[94mrng algorithm: \e[96m" #ALG "\n");\
|
kprintf("\e[94mrng algorithm: \e[96m" #ALG "\n");\
|
||||||
void* s= ALG##_init(0);\
|
void* s= ALG##_init(0);\
|
||||||
uint##VALUE_SIZE r=ALG##_next(s);\
|
uint##VALUE_SIZE r=ALG##_next(s);\
|
||||||
printf("\e[97m next from zero seed:");\
|
kprintf("\e[97m next from zero seed:");\
|
||||||
if(r!=EXPECTED_FROM_ZERO){\
|
if(r!=EXPECTED_FROM_ZERO){\
|
||||||
printf("\e[91m " IFWIN("%llu\n","%lu\n"), (uint64)r);\
|
kprintf("\e[91m " IFWIN("%llu\n","%lu\n"), (uint64)r);\
|
||||||
throw(ERR_UNEXPECTEDVAL);\
|
throw(ERR_UNEXPECTEDVAL);\
|
||||||
}\
|
}\
|
||||||
printf("\e[92m " IFWIN("%llu\n","%lu\n"), (uint64)r);\
|
kprintf("\e[92m " IFWIN("%llu\n","%lu\n"), (uint64)r);\
|
||||||
ALG##_free(s);\
|
ALG##_free(s);\
|
||||||
s= ALG##_initFromTime();\
|
s= ALG##_initFromTime();\
|
||||||
r=ALG##_next(s);\
|
r=ALG##_next(s);\
|
||||||
ALG##_free(s);\
|
ALG##_free(s);\
|
||||||
printf("\e[97m next from time seed:\e[92m " IFWIN("%llu\n","%lu\n"), (uint64)r);\
|
kprintf("\e[97m next from time seed:\e[92m " IFWIN("%llu\n","%lu\n"), (uint64)r);\
|
||||||
}
|
}
|
||||||
|
|
||||||
void test_rng_algorithms(){
|
void test_rng_algorithms(){
|
||||||
optime("test_rng_algorithms",1,({
|
optime("test_rng_algorithms",1,({
|
||||||
printf("\e[96m--------[test_rng_algorithms]---------\n");
|
kprintf("\e[96m--------[test_rng_algorithms]---------\n");
|
||||||
// for ALG32
|
// for ALG32
|
||||||
// xoroshiro64
|
// xoroshiro64
|
||||||
test_alg(xoroshiro64star, 32, 932574677ULL)
|
test_alg(xoroshiro64star, 32, 932574677ULL)
|
||||||
|
|||||||
@ -14,10 +14,10 @@ Maybe throw_errcode(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
Maybe test_maybe(){
|
Maybe test_maybe(){
|
||||||
printf("\e[94mdont_throw returns \e[92m");
|
kprintf("\e[94mdont_throw returns \e[92m");
|
||||||
tryLast(dont_throw(),rez0)
|
tryLast(dont_throw(),rez0)
|
||||||
printMaybe(rez0);
|
printMaybe(rez0);
|
||||||
printf("\n");
|
kprintf("\n");
|
||||||
try(throw_error(),rez1,;)
|
try(throw_error(),rez1,;)
|
||||||
printMaybe(rez1);
|
printMaybe(rez1);
|
||||||
throw("test_maybe failed");
|
throw("test_maybe failed");
|
||||||
@ -29,13 +29,13 @@ Maybe b(){ try(c(),_,;) return MaybeNull; }
|
|||||||
Maybe a(){ try(b(),_,;) return MaybeNull; }
|
Maybe a(){ try(b(),_,;) return MaybeNull; }
|
||||||
|
|
||||||
void test_safethrow(){
|
void test_safethrow(){
|
||||||
printf("\e[96m-----------[test_safethrow]-----------\n");
|
kprintf("\e[96m-----------[test_safethrow]-----------\n");
|
||||||
optime("test_safethrow", 1, ({
|
optime("test_safethrow", 1, ({
|
||||||
Maybe e=test_maybe();
|
Maybe e=test_maybe();
|
||||||
printf("\e[94mthrow_error:\n\e[92m");
|
kprintf("\e[94mthrow_error:\n\e[92m");
|
||||||
printMaybe(e);
|
printMaybe(e);
|
||||||
Maybe_free(e);
|
Maybe_free(e);
|
||||||
printf("\e[94mthrow_errcode:\n\e[92m");
|
kprintf("\e[94mthrow_errcode:\n\e[92m");
|
||||||
e=a();
|
e=a();
|
||||||
printMaybe(e);
|
printMaybe(e);
|
||||||
Maybe_free(e);
|
Maybe_free(e);
|
||||||
|
|||||||
@ -2,21 +2,21 @@
|
|||||||
#include "../src/SearchTree/SearchTree.h"
|
#include "../src/SearchTree/SearchTree.h"
|
||||||
|
|
||||||
void printstnode(STNode* node){
|
void printstnode(STNode* node){
|
||||||
printf("\e[94mSTNode: "
|
kprintf("\e[94mSTNode: "
|
||||||
IFWIN("%llu", "%lu")
|
IFWIN("%llu", "%lu")
|
||||||
"\n address: %p\n value: ",sizeof(STNode),node);
|
"\n address: %p\n value: ",sizeof(STNode),node);
|
||||||
printuni(node->value);
|
printuni(node->value);
|
||||||
printf("\n");
|
kprintf("\n");
|
||||||
// prints pointers to all existing branches
|
// prints pointers to all existing branches
|
||||||
/* printf(" branches: %p\n", node->branches);
|
/* kprintf(" branches: %p\n", node->branches);
|
||||||
if(node->branches) for(uint8 i=0;i<8;i++){
|
if(node->branches) for(uint8 i=0;i<8;i++){
|
||||||
printf(" \e[90m[%u]=%p\n",i,node->branches[i]);
|
kprintf(" \e[90m[%u]=%p\n",i,node->branches[i]);
|
||||||
if(node->branches[i])
|
if(node->branches[i])
|
||||||
for (uint8 ii = 0; ii < 8; ii++){
|
for (uint8 ii = 0; ii < 8; ii++){
|
||||||
printf(" \e[90m[%u]=%p\n",ii,node->branches[i][ii]);
|
kprintf(" \e[90m[%u]=%p\n",ii,node->branches[i][ii]);
|
||||||
if(node->branches[i][ii])
|
if(node->branches[i][ii])
|
||||||
for (uint8 iii = 0; iii < 4; iii++)
|
for (uint8 iii = 0; iii < 4; iii++)
|
||||||
printf(" \e[90m[%u]=%p\n",iii,node->branches[i][ii][iii]);
|
kprintf(" \e[90m[%u]=%p\n",iii,node->branches[i][ii][iii]);
|
||||||
}
|
}
|
||||||
|
|
||||||
} */
|
} */
|
||||||
@ -24,51 +24,51 @@ void printstnode(STNode* node){
|
|||||||
|
|
||||||
void test_searchtree(){
|
void test_searchtree(){
|
||||||
optime("test_searchtree",1,({
|
optime("test_searchtree",1,({
|
||||||
printf("\e[96m-----------[test_searchtree]----------\n");
|
kprintf("\e[96m-----------[test_searchtree]----------\n");
|
||||||
STNode* node=STNode_create();
|
STNode* node=STNode_create();
|
||||||
printf("\e[92mnode created\n");
|
kprintf("\e[92mnode created\n");
|
||||||
printf("push:\e[94m\n ");
|
kprintf("push:\e[94m\n ");
|
||||||
Unitype u=UniInt64(-3);
|
Unitype u=UniInt64(-3);
|
||||||
printuni(u);
|
printuni(u);
|
||||||
ST_push(node,"type", u);
|
ST_push(node,"type", u);
|
||||||
printf(" -> type\n ");
|
kprintf(" -> type\n ");
|
||||||
u=UniInt64(25);
|
u=UniInt64(25);
|
||||||
printuni(u);
|
printuni(u);
|
||||||
ST_push(node,"time", u);
|
ST_push(node,"time", u);
|
||||||
printf(" -> time\n ");
|
kprintf(" -> time\n ");
|
||||||
u=UniFloat64(-542.00600);
|
u=UniFloat64(-542.00600);
|
||||||
printuni(u);
|
printuni(u);
|
||||||
ST_push(node,"author_id", u);
|
ST_push(node,"author_id", u);
|
||||||
printf(" -> author_id\n ");
|
kprintf(" -> author_id\n ");
|
||||||
u=UniInt64(-31255);
|
u=UniInt64(-31255);
|
||||||
printuni(u);
|
printuni(u);
|
||||||
ST_push(node,"channel_id", u);
|
ST_push(node,"channel_id", u);
|
||||||
printf(" -> channel_id\n ");
|
kprintf(" -> channel_id\n ");
|
||||||
u=UniHeap(ktId_CharPtr, cptr_copy("32.2004"));
|
u=UniHeap(ktId_CharPtr, cptr_copy("32.2004"));
|
||||||
printuni(u);
|
printuni(u);
|
||||||
ST_push(node,"message_id", u);
|
ST_push(node,"message_id", u);
|
||||||
printf(" -> message_id\n ");
|
kprintf(" -> message_id\n ");
|
||||||
u=UniStack(ktId_CharPtr,"some text UwU");
|
u=UniStack(ktId_CharPtr,"some text UwU");
|
||||||
printuni(u);
|
printuni(u);
|
||||||
ST_push(node,"text", u);
|
ST_push(node,"text", u);
|
||||||
printf(" -> text\n");
|
kprintf(" -> text\n");
|
||||||
printf("\e[92mpull:\e[94m");
|
kprintf("\e[92mpull:\e[94m");
|
||||||
printf("\n type -> ");
|
kprintf("\n type -> ");
|
||||||
printuni(ST_pull(node,"type"));
|
printuni(ST_pull(node,"type"));
|
||||||
printf("\n time -> ");
|
kprintf("\n time -> ");
|
||||||
printuni(ST_pull(node,"time"));
|
printuni(ST_pull(node,"time"));
|
||||||
printf("\n author_id -> ");
|
kprintf("\n author_id -> ");
|
||||||
printuni(ST_pull(node,"author_id"));
|
printuni(ST_pull(node,"author_id"));
|
||||||
printf("\n channel_id -> ");
|
kprintf("\n channel_id -> ");
|
||||||
printuni(ST_pull(node,"channel_id"));
|
printuni(ST_pull(node,"channel_id"));
|
||||||
printf("\n message_id -> ");
|
kprintf("\n message_id -> ");
|
||||||
printuni(ST_pull(node,"message_id"));
|
printuni(ST_pull(node,"message_id"));
|
||||||
printf("\n text -> ");
|
kprintf("\n text -> ");
|
||||||
printuni(ST_pull(node,"text"));
|
printuni(ST_pull(node,"text"));
|
||||||
printf("\n");
|
kprintf("\n");
|
||||||
printf("\e[92mfirst node: ");
|
kprintf("\e[92mfirst node: ");
|
||||||
printstnode(node);
|
printstnode(node);
|
||||||
STNode_free(node);
|
STNode_free(node);
|
||||||
printf("\e[92mnode deleted\n");
|
kprintf("\e[92mnode deleted\n");
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|||||||
@ -3,12 +3,12 @@
|
|||||||
|
|
||||||
void test_string(){
|
void test_string(){
|
||||||
optime(__func__,1,({
|
optime(__func__,1,({
|
||||||
printf("\e[96m-------------[test_string]------------\n");
|
kprintf("\e[96m-------------[test_string]------------\n");
|
||||||
char c[]="0123456789abcdef";
|
char c[]="0123456789abcdef";
|
||||||
string s={.ptr=c, .length=cptr_length(c)};
|
string s={.ptr=c, .length=cptr_length(c)};
|
||||||
if(s.length!=sizeof(c)-1) throw("string created with incorrect length");
|
if(s.length!=sizeof(c)-1) throw("string created with incorrect length");
|
||||||
char* p=string_extract(s);
|
char* p=string_extract(s);
|
||||||
printf("\e[94mstring_extract() -> \e[92m\"%s\"\n",p);
|
kprintf("\e[94mstring_extract() -> \e[92m\"%s\"\n",p);
|
||||||
free(p);
|
free(p);
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
@ -17,7 +17,7 @@ void test_kprint_colors();
|
|||||||
void test_autoarrVsVector();
|
void test_autoarrVsVector();
|
||||||
void test_rng_algorithms();
|
void test_rng_algorithms();
|
||||||
|
|
||||||
#define PRINT_SIZEOF(T) printf("\e[94m" #T " size: \e[96m" IFWIN("%llu", "%lu") "\n", sizeof(T))
|
#define PRINT_SIZEOF(T) kprintf("\e[94m" #T " size: \e[96m" IFWIN("%llu", "%lu") "\n", sizeof(T))
|
||||||
|
|
||||||
#if __cplusplus
|
#if __cplusplus
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user