fuck go back
This commit is contained in:
@@ -1,11 +1,10 @@
|
||||
#include "tests.h"
|
||||
|
||||
void test_all(){
|
||||
test_autoarr();
|
||||
test_string();
|
||||
test_safethrow();
|
||||
test_searchtree();
|
||||
test_autoarr();
|
||||
test_hashtable();
|
||||
test_string();
|
||||
test_dtsod();
|
||||
printf("\e[96m---------------------------------------\e[0m\n");
|
||||
}
|
||||
|
||||
@@ -4,11 +4,12 @@
|
||||
const char text[]=
|
||||
"message: {\n"
|
||||
" bool: false;"
|
||||
" char: 'v';"
|
||||
" int: -2515;"
|
||||
" uint:#comment!\n 0u;"
|
||||
" double: 965.557f;#another comment!\n"
|
||||
" text: \"_$\\\"\\\\'''a ыыы000;2;=:%d;```\";\n"
|
||||
"};";
|
||||
"}; ";
|
||||
|
||||
void print_dtsod(Hashtable* dtsod){
|
||||
printf("\e[92m");
|
||||
@@ -32,21 +33,18 @@ void test_dtsod(){
|
||||
optime(__func__,1,({
|
||||
printf("\e[96m-------------[test_dtsod]-------------\n");
|
||||
Hashtable* dtsod;
|
||||
char* s=cptr_copy(text);
|
||||
|
||||
optime("deserialize",1,({
|
||||
tryLast(DtsodV24_deserialize(text),r)
|
||||
dtsod=r.value.VoidPtr;
|
||||
}));
|
||||
optime("deserialize",1,(dtsod=DtsodV24_deserialize(s)));
|
||||
free(s);
|
||||
print_dtsod(dtsod);
|
||||
|
||||
char* s;
|
||||
optime("serialize",1,(s=DtsodV24_serialize(dtsod)));
|
||||
Hashtable_free(dtsod);
|
||||
printf("\e[92m%s",s);
|
||||
|
||||
optime("reserialize",10,({
|
||||
tryLast(DtsodV24_deserialize(s),r)
|
||||
dtsod=r.value.VoidPtr;
|
||||
dtsod=DtsodV24_deserialize(s);
|
||||
free(s);
|
||||
s=DtsodV24_serialize(dtsod);
|
||||
Hashtable_free(dtsod);
|
||||
|
||||
@@ -39,10 +39,7 @@ void printrowgraph(Hashtable* ht){
|
||||
void fill(Hashtable* ht){
|
||||
for(uint32 i=0;i<100000;i++){
|
||||
char* key=malloc(12);
|
||||
IFWIN(
|
||||
sprintf_s(key,12,"key_%u",i),
|
||||
sprintf(key,"key_%u",i)
|
||||
);
|
||||
sprintf(key,"key__%u",i);
|
||||
Hashtable_add(ht,key,Uni(UInt64,i));
|
||||
}
|
||||
}
|
||||
@@ -51,10 +48,7 @@ Unitype gett(Hashtable* ht){
|
||||
char* key=malloc(12);
|
||||
Unitype u;
|
||||
for(uint32 i=0;i<100000;i++){
|
||||
IFWIN(
|
||||
sprintf_s(key,12,"key_%u",i),
|
||||
sprintf(key,"key_%u",i)
|
||||
);
|
||||
sprintf(key,"key__%u",i);
|
||||
u=Hashtable_get(ht,key);
|
||||
}
|
||||
free(key);
|
||||
|
||||
@@ -1,43 +0,0 @@
|
||||
#include "tests.h"
|
||||
|
||||
Maybe dont_throw(){
|
||||
return SUCCESS(Uni(UInt64, 9/2));
|
||||
}
|
||||
|
||||
Maybe throw_error(){
|
||||
safethrow("test exception");
|
||||
}
|
||||
|
||||
Maybe throw_errcode(){
|
||||
safethrow(ERR_NULLPTR);
|
||||
}
|
||||
|
||||
Maybe test_maybe(){
|
||||
printf("\e[94mdont_throw returns \e[92m");
|
||||
tryLast(dont_throw(),rez0)
|
||||
printMaybe(rez0);
|
||||
printf("\n");
|
||||
try(throw_error(),rez1)
|
||||
printMaybe(rez1);
|
||||
throw("test_maybe failed");
|
||||
return MaybeNull;
|
||||
}
|
||||
|
||||
|
||||
Maybe c(){ try(throw_errcode(),_) return MaybeNull; }
|
||||
Maybe b(){ try(c(),_) return MaybeNull; }
|
||||
Maybe a(){ try(b(),_) return MaybeNull; }
|
||||
|
||||
void test_safethrow(){
|
||||
printf("\e[96m-----------[test_safethrow]-----------\n");
|
||||
optime("test_safethrow", 1, ({
|
||||
Maybe e=test_maybe();
|
||||
printf("\e[94mthrow_error:\n\e[92m");
|
||||
printMaybe(e);
|
||||
Maybe_free(e);
|
||||
printf("\e[94mthrow_errcode:\n\e[92m");
|
||||
e=a();
|
||||
printMaybe(e);
|
||||
Maybe_free(e);
|
||||
}));
|
||||
}
|
||||
@@ -6,10 +6,10 @@ void test_string(){
|
||||
printf("\e[96m-------------[test_string]-------------\n");
|
||||
char c[]="0123456789abcdef";
|
||||
string s=string_cpFromCharPtr(c);
|
||||
printf("\e[92m\"%s\" \e[94m-> string_cpFromCharPtr()\n",c);
|
||||
printf("\e[92m\"%s\" -> string_cpFromCharPtr()\n",c);
|
||||
if(s.length!=16) throw("string created with incorrect length");
|
||||
char* p=string_cpToCptr(s);
|
||||
printf("\e[94mstring_cpToCptr() -> \e[92m\"%s\"\n",p);
|
||||
printf("\e[92mstring_cpToCptr() -> \"%s\"\n",p);
|
||||
free(p);
|
||||
free(s.ptr);
|
||||
}));
|
||||
|
||||
@@ -8,5 +8,4 @@ void test_searchtree();
|
||||
void test_autoarr();
|
||||
void test_hashtable();
|
||||
void test_string();
|
||||
void test_dtsod();
|
||||
void test_safethrow();
|
||||
void test_dtsod();
|
||||
Reference in New Issue
Block a user