serialize()

This commit is contained in:
2022-03-04 14:32:09 +03:00
parent 8c9431460e
commit 6cc3acea1d
19 changed files with 295 additions and 45 deletions

View File

@@ -1,24 +1,11 @@
#include "../base/base.h"
#include "tests.h"
void printuni(Unitype v){
switch (v.type) {
case Null: printf("{Null}");break;
case Double: printf("{%s:%lf}",typename(v.type),v.Double);break;
case Char: printf("{%s:%c}",typename(v.type),v.Char);break;
case Bool:
case UInt64: printf("{%s:%lu}",typename(v.type),v.UInt64);break;
case Int64: printf("{%s:%ld}",typename(v.type),v.Int64);break;
default: printf("{%s:%p}",typename(v.type),v.VoidPtr);break;
}
}
void test_all(){
test_searchtree();
test_autoarr();
test_hashtable();
test_string();
//test_searchtree();
//test_autoarr();
//test_hashtable();
//test_string();
test_dtsod();
printf("\e[96m---------------------------------------\e[0m\n");
}

View File

@@ -14,15 +14,18 @@ void test_dtsod(){
" message_id: 920734809096077353ul;\n"
" text: \"_$\\\"\\\\'''\n\ta ыыы000;2;=:%d;```\";\n"
"};\n";
Unitype id;
KeyValuePair id;
Hashtable* dtsod;
optime("deserialize",1,(dtsod=DtsodV24_deserialize(text)));
printf("\e[92mhashtable_get(message)->\n\e[94m");
Unitype msg=Hashtable_get(dtsod,"message");
printuni(msg);
Autoarr(Unitype)* ar=msg.VoidPtr;
id=Hashtable_get(Autoarr_get(ar,0).VoidPtr,"message_id");
printf("\e[92m\nmessage_id: %lu\n",id.UInt64);
printf("\e[92mhashtable_get(\"message\")->\n\e[94m");
KeyValuePair msg=Hashtable_get_pair(dtsod,"message");
printkvp(msg);
printf("\n");
Autoarr(Unitype)* ar=msg.value.VoidPtr;
printf("\e[92mhashtable_get(\"message_id\")->\n\e[94m");
id=Hashtable_get_pair(Autoarr_get(ar,0).VoidPtr,"message_id");
printkvp(id);
printf("\n");
Hashtable_free(dtsod);
}));
}

View File

@@ -1,12 +1,6 @@
#include "tests.h"
#include "../Hashtable/Hashtable.h"
void printkvp(KeyValuePair p){
printf("{\"%s\", ",p.key);
printuni(p.value);
printf("}");
}
void print_hashtable(Hashtable* ht){
printf("\e[94mHashtable:%lu\n"
" hein: %u\n"