64
This commit is contained in:
parent
7b0426fa75
commit
a9d10b0895
8
.vscode/settings.json
vendored
8
.vscode/settings.json
vendored
@ -1,5 +1,11 @@
|
|||||||
{
|
{
|
||||||
"files.associations": {
|
"files.associations": {
|
||||||
"*.h": "c"
|
"*.h": "c",
|
||||||
|
"type_traits": "c",
|
||||||
|
"*.tcc": "c",
|
||||||
|
"functional": "c",
|
||||||
|
"istream": "c",
|
||||||
|
"ranges": "c",
|
||||||
|
"streambuf": "c"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1,38 +1,33 @@
|
|||||||
SRC=src/*.c
|
SRC=$(wildcard src/*c) $(wildcard src/**/*.c)
|
||||||
OUTDIR=bin/
|
OUTDIR=bin/
|
||||||
OUTFILE=dtsodc.com
|
OUTFILE=dtsodc.com
|
||||||
|
CMP=gcc
|
||||||
all: clear_c clear_bin test
|
all: clear_c build test
|
||||||
|
std: clear_c std_build std_test
|
||||||
|
|
||||||
clear_c:
|
clear_c:
|
||||||
clear
|
clear
|
||||||
|
|
||||||
clear_bin:
|
clear_bin:
|
||||||
@echo "\e[36m-----------------[clear_bin]-------------------\e[0m"
|
@echo "\e[36m-----------------[clear_bin]-------------------\e[0m"
|
||||||
touch $(OUTDIR)_.com
|
touch $(OUTDIR)_.com
|
||||||
rm $(OUTDIR)*.com
|
rm $(OUTDIR)*.com
|
||||||
|
|
||||||
# using sdlib
|
# using sdlib
|
||||||
STDARGS=-D STDLIB
|
STDARGS=-D STDLIB -O
|
||||||
|
|
||||||
std_build:
|
std_build:
|
||||||
@echo "\e[36m-------------[std_build]---------------\e[0m"
|
@echo "\e[36m-------------[std_build]---------------\e[0m"
|
||||||
gcc $(STDARGS) $(SRC) -o $(OUTDIR)std_$(OUTFILE)
|
$(CMP) $(STDARGS) $(SRC) -o $(OUTDIR)std_$(OUTFILE)
|
||||||
|
std_test:
|
||||||
std_test: std_build
|
|
||||||
@echo "\e[36m----------------[std_test]------------------\e[0m"
|
@echo "\e[36m----------------[std_test]------------------\e[0m"
|
||||||
$(OUTDIR)std_$(OUTFILE)
|
$(OUTDIR)std_$(OUTFILE)
|
||||||
|
|
||||||
|
|
||||||
# using cosmopolitan
|
# using cosmopolitan
|
||||||
COSMARGS_PRE=-g -O -static -fno-pie -no-pie -mno-red-zone -nostdlib -nostdinc -D COSMOPOLITAN
|
COSMARGS_PRE=-g -O -static -fno-pie -no-pie -mno-red-zone -nostdlib -nostdinc -D COSMOPOLITAN
|
||||||
COSMARGS_POST=-Wl,--oformat=binary -Wl,--gc-sections -Wl,-z,max-page-size=0x1000 -fuse-ld=bfd -Wl,-T,cosmopolitan/ape.lds \
|
COSMARGS_POST=-Wl,--oformat=binary -Wl,--gc-sections -Wl,-z,max-page-size=0x1000 -fuse-ld=bfd -Wl,-T,cosmopolitan/ape.lds \
|
||||||
-include cosmopolitan/cosmopolitan.h cosmopolitan/crt.o ./cosmopolitan/ape.o cosmopolitan/cosmopolitan.a
|
-include cosmopolitan/cosmopolitan.h cosmopolitan/crt.o ./cosmopolitan/ape.o cosmopolitan/cosmopolitan.a
|
||||||
|
|
||||||
build:
|
build:
|
||||||
@echo "\e[36m----------------[build]----------------\e[0m"
|
@echo "\e[36m----------------[build]----------------\e[0m"
|
||||||
gcc $(COSMARGS_PRE) $(SRC) $(COSMARGS_POST) -o $(OUTDIR)$(OUTFILE)
|
$(CMP) $(COSMARGS_PRE) $(SRC) $(COSMARGS_POST) -o $(OUTDIR)$(OUTFILE)
|
||||||
|
test:
|
||||||
test: build
|
|
||||||
@echo "\e[36m-----------------[test]----------------\e[0m"
|
@echo "\e[36m-----------------[test]----------------\e[0m"
|
||||||
$(OUTDIR)$(OUTFILE)
|
$(OUTDIR)$(OUTFILE)
|
||||||
@ -20,5 +20,5 @@ make build
|
|||||||
|
|
||||||
If you see the `run-detectors: unable to find an interpreter` error, just execute this command:
|
If you see the `run-detectors: unable to find an interpreter` error, just execute this command:
|
||||||
```bash
|
```bash
|
||||||
sudo sh -c "echo ':APE:M::MZqFpD::/bin/sh:' >/proc/sys/fs/binfmt_misc/register"
|
sudo echo ':APE:M::MZqFpD::/bin/sh:' >/proc/sys/fs/binfmt_misc/register
|
||||||
```
|
```
|
||||||
@ -144,7 +144,7 @@ void Autoarr_set_uint64(Autoarr *ar, uint32 index, uint64 element){
|
|||||||
*(*((uint64**)ar->values+d.quot)+d.rem)=element;
|
*(*((uint64**)ar->values+d.quot)+d.rem)=element;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Autoarr_free(Autoarr* ar){
|
void Autoarr_clear(Autoarr* ar){
|
||||||
switch (ar->type) {
|
switch (ar->type) {
|
||||||
case Int8:
|
case Int8:
|
||||||
for(uint16 i = 0; i < ar->curr_block_count-1;i++)
|
for(uint16 i = 0; i < ar->curr_block_count-1;i++)
|
||||||
@ -1,10 +1,8 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "std.h"
|
#include "../base/base.h"
|
||||||
#include "base_types.h"
|
|
||||||
#include "errors.h"
|
|
||||||
|
|
||||||
typedef struct Autoarr{
|
typedef struct Autoarr{ // a collection with dynamic memory allocation
|
||||||
base_type type; // type of data
|
base_type type; // type of data
|
||||||
uint16 max_block_count; // max amount of blocks
|
uint16 max_block_count; // max amount of blocks
|
||||||
uint16 curr_block_count; // amount of blocks
|
uint16 curr_block_count; // amount of blocks
|
||||||
@ -16,6 +14,7 @@ typedef struct Autoarr{
|
|||||||
} Autoarr;
|
} Autoarr;
|
||||||
|
|
||||||
Autoarr Autoarr_create(uint16 _max_block_count, uint16 _max_block_length, base_type _type);
|
Autoarr Autoarr_create(uint16 _max_block_count, uint16 _max_block_length, base_type _type);
|
||||||
|
void Autoarr_clear(Autoarr* ar);
|
||||||
|
|
||||||
void Autoarr_add_int8(Autoarr *ar, int8 element);
|
void Autoarr_add_int8(Autoarr *ar, int8 element);
|
||||||
void Autoarr_add_uint8(Autoarr *ar, uint8 element);
|
void Autoarr_add_uint8(Autoarr *ar, uint8 element);
|
||||||
@ -43,5 +42,3 @@ void Autoarr_set_int32(Autoarr *ar, uint32 index, int32 element);
|
|||||||
void Autoarr_set_uint32(Autoarr *ar, uint32 index, uint32 element);
|
void Autoarr_set_uint32(Autoarr *ar, uint32 index, uint32 element);
|
||||||
void Autoarr_set_int64(Autoarr *ar, uint32 index, int64 element);
|
void Autoarr_set_int64(Autoarr *ar, uint32 index, int64 element);
|
||||||
void Autoarr_set_uint64(Autoarr *ar, uint32 index, uint64 element);
|
void Autoarr_set_uint64(Autoarr *ar, uint32 index, uint64 element);
|
||||||
|
|
||||||
void Autoarr_free(Autoarr* ar);
|
|
||||||
@ -1,2 +0,0 @@
|
|||||||
|
|
||||||
|
|
||||||
@ -1,2 +0,0 @@
|
|||||||
|
|
||||||
|
|
||||||
72
DtsodC/src/SearchTree/SearchTree.c
Normal file
72
DtsodC/src/SearchTree/SearchTree.c
Normal file
@ -0,0 +1,72 @@
|
|||||||
|
#include "SearchTree.h"
|
||||||
|
|
||||||
|
STNode* STNode_create(){
|
||||||
|
STNode* node=malloc(sizeof(STNode));
|
||||||
|
node->branches=NULL;
|
||||||
|
node->value.ptr=NULL;
|
||||||
|
node->value.type=Null;
|
||||||
|
return node;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void STNode_free(STNode* node){
|
||||||
|
ifNthrow(node);
|
||||||
|
if(node->branches!=NULL){
|
||||||
|
for(uint8 n32 = 0;n32<8;n32++){
|
||||||
|
STNode*** ptrn32=(STNode***)node->branches[n32];
|
||||||
|
if(ptrn32!=NULL){
|
||||||
|
for(uint8 n4 = 0;n4<8;n4++){
|
||||||
|
STNode** ptrn4=ptrn32[n4];
|
||||||
|
if (ptrn4!=NULL){
|
||||||
|
for(uint8 rem=0;rem<4;rem++){
|
||||||
|
STNode* ptrrem=ptrn4[rem];
|
||||||
|
if(ptrrem!=NULL){
|
||||||
|
STNode_free(ptrrem);
|
||||||
|
free(ptrrem);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
free(ptrn4);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
free(ptrn32);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
free(node->branches);
|
||||||
|
}
|
||||||
|
free(node->value.ptr);
|
||||||
|
free(node);
|
||||||
|
}
|
||||||
|
|
||||||
|
typedef struct {uint8 n32, n4, rem;} indexes3;
|
||||||
|
|
||||||
|
indexes3 splitindex(uint8 i){
|
||||||
|
return (indexes3){
|
||||||
|
.n32=i/32,
|
||||||
|
.n4=i%32/4,
|
||||||
|
.rem=i%32%4,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8 combinei3(indexes3 i3){
|
||||||
|
return i3.n32*32+i3.n4*8;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// returns NULL or *STNode corresponding to the character
|
||||||
|
STNode* getcnode(STNode* node, uint8 c){
|
||||||
|
indexes3 i3=splitindex(c);
|
||||||
|
ifNretN(node->branches);
|
||||||
|
STNode*** ptrn32=(STNode***)node->branches[i3.n32];
|
||||||
|
ifNretN(ptrn32);
|
||||||
|
STNode** ptrn4=ptrn32[i3.n4];
|
||||||
|
ifNretN(ptrn4);
|
||||||
|
return ptrn4[i3.rem];
|
||||||
|
}
|
||||||
|
|
||||||
|
void ST_push(STNode* node, const char* key, Unitype value){
|
||||||
|
char c = *key;
|
||||||
|
for (uint16 i=0;c!='\0';){
|
||||||
|
printf("[%u]%c ",i,c);
|
||||||
|
c=*(key+(++i));
|
||||||
|
}
|
||||||
|
}
|
||||||
19
DtsodC/src/SearchTree/SearchTree.h
Normal file
19
DtsodC/src/SearchTree/SearchTree.h
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "../base/base.h"
|
||||||
|
|
||||||
|
typedef struct UniversalType{
|
||||||
|
base_type type;
|
||||||
|
void* ptr;
|
||||||
|
} Unitype;
|
||||||
|
|
||||||
|
typedef struct SearchTreeNode{
|
||||||
|
struct SearchTreeNode**** branches; //*STNode[8][8][4]
|
||||||
|
Unitype value;
|
||||||
|
} STNode;
|
||||||
|
|
||||||
|
STNode* STNode_create(void);
|
||||||
|
void STNode_free(STNode* node);
|
||||||
|
|
||||||
|
void ST_push(STNode* node, const char* key, Unitype value);
|
||||||
|
Unitype ST_pull(STNode* node, const char* key);
|
||||||
25
DtsodC/src/SearchTree/SearchTree.md
Normal file
25
DtsodC/src/SearchTree/SearchTree.md
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
# Search Tree
|
||||||
|
|
||||||
|
byte is dividing into indexes of 3d array of nodes
|
||||||
|
```
|
||||||
|
STNode.branches byte
|
||||||
|
┃
|
||||||
|
┣━[0]━┳━[0]━┳━[0] 0
|
||||||
|
┃ ┃ ┣━...
|
||||||
|
┃ ┃ ┗━[3] 3
|
||||||
|
┃ ┣━...
|
||||||
|
┃ ┃
|
||||||
|
┃ ┗━[7]━┳━[0] 28
|
||||||
|
┃ ┣━...
|
||||||
|
┃ ┗━[3] 31
|
||||||
|
┣━...
|
||||||
|
┃
|
||||||
|
┗━[7]━┳━[0]━┳━[0] 224
|
||||||
|
┃ ┣━...
|
||||||
|
┃ ┗━[3] 227
|
||||||
|
┣━...
|
||||||
|
┃
|
||||||
|
┗━[7]━┳━[0] 252
|
||||||
|
┣━...
|
||||||
|
┗━[3] 255
|
||||||
|
```
|
||||||
3
DtsodC/src/base/base.h
Normal file
3
DtsodC/src/base/base.h
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
#include "std.h"
|
||||||
|
#include "base_types.h"
|
||||||
|
#include "errors.h"
|
||||||
@ -13,7 +13,7 @@ const char* typename(base_type t){
|
|||||||
case UInt32: return "UInt32";
|
case UInt32: return "UInt32";
|
||||||
case Int64: return "Int64";
|
case Int64: return "Int64";
|
||||||
case UInt64: return "UInt64";
|
case UInt64: return "UInt64";
|
||||||
default: throw(ERR_WRONGTYPE); break;
|
default: throw(ERR_WRONGTYPE); return "EEEEEE";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -11,10 +11,9 @@ typedef int32_t int32;
|
|||||||
typedef uint32_t uint32;
|
typedef uint32_t uint32;
|
||||||
typedef int64_t int64;
|
typedef int64_t int64;
|
||||||
typedef uint64_t uint64;
|
typedef uint64_t uint64;
|
||||||
|
|
||||||
typedef enum base_type{
|
typedef enum base_type{
|
||||||
Null,Int8, Int16, Int32, Int64, UInt8, UInt16, UInt32, UInt64
|
Null, Int8, Int16, Int32, Int64, UInt8, UInt16, UInt32, UInt64, Char, Bool
|
||||||
} base_type;
|
} __attribute__ ((__packed__)) base_type;
|
||||||
|
|
||||||
const char* typename(base_type t);
|
const char* typename(base_type t);
|
||||||
|
|
||||||
|
|||||||
@ -8,15 +8,19 @@ const char* errname(err_t err){
|
|||||||
case ERR_WRONGTYPE: return "ERR_WRONGTYPE";
|
case ERR_WRONGTYPE: return "ERR_WRONGTYPE";
|
||||||
case ERR_WRONGINDEX: return "ERR_WRONGINDEX";
|
case ERR_WRONGINDEX: return "ERR_WRONGINDEX";
|
||||||
case ERR_NOTIMPLEMENTED: return "ERR_NOTIMPLEMENTED";
|
case ERR_NOTIMPLEMENTED: return "ERR_NOTIMPLEMENTED";
|
||||||
|
case ERR_NULLPTR: return "ERR_NULLPTR";
|
||||||
default: return "UNKNOWN_ERROR";
|
default: return "UNKNOWN_ERROR";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void _throwint(int err, const char* srcfile, int line, const char* funcname){
|
void _throwint(int err, const char* srcfile, int line, const char* funcname){
|
||||||
printf("\e[31m[%s:%d/%s] throwed error: %s\e[0m\n",srcfile,line,funcname,errname(err));
|
if(err){ // SUCCESS=0 is not an error
|
||||||
|
printf("\e[91m[%s:%d/%s] throwed error: %s\e[0m\n",srcfile,line,funcname,errname(err));
|
||||||
exit(err);
|
exit(err);
|
||||||
}
|
}
|
||||||
|
else printf("\e[93m[%s:%d/%s] throwed SUCCESS as an error",srcfile,line,funcname);
|
||||||
|
}
|
||||||
void _throwstr(const char* errmesg, const char* srcfile, int line, const char* funcname){
|
void _throwstr(const char* errmesg, const char* srcfile, int line, const char* funcname){
|
||||||
printf("\e[31m[%s:%d/%s] throwed error: %s\e[0m\n",srcfile,line,funcname,errmesg);
|
printf("\e[91m[%s:%d/%s] throwed error: %s\e[0m\n",srcfile,line,funcname,errmesg);
|
||||||
exit(255);
|
exit(255);
|
||||||
}
|
}
|
||||||
@ -1,14 +1,20 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
typedef enum err_t {
|
typedef enum err_t {
|
||||||
SUCCESS, ERR_MAXLENGTH, ERR_WRONGTYPE, ERR_WRONGINDEX, ERR_NOTIMPLEMENTED
|
SUCCESS, //not an error
|
||||||
|
ERR_MAXLENGTH, ERR_WRONGTYPE, ERR_WRONGINDEX, ERR_NOTIMPLEMENTED, ERR_NULLPTR
|
||||||
} err_t;
|
} err_t;
|
||||||
|
|
||||||
const char* errname(err_t err);
|
const char* errname(err_t err);
|
||||||
|
|
||||||
void _throwint(int err, const char* srcfile, int line, const char* funcname);
|
void _throwint(int err, const char* srcfile, int line, const char* funcname);
|
||||||
void _throwstr(const char* errmesg, const char* srcfile, int line, const char* funcname);
|
void _throwstr(const char* errmesg, const char* srcfile, int line, const char* funcname);
|
||||||
#pragma GCC diagnostic ignored "-Wint-conversion"
|
#pragma GCC diagnostic ignored "-Wint-conversion"
|
||||||
#define throw(E) \
|
#define throw(E) \
|
||||||
CHOOSE(IFTYPE(E,int), _throwint(E,__FILE__,__LINE__,__func__), \
|
CHOOSE(IFTYPE(E,int), _throwint(E,__FILE__,__LINE__,__func__), \
|
||||||
CHOOSE(IFTYPE(E,char[]), _throwstr(E,__FILE__,__LINE__,__func__), \
|
CHOOSE(IFTYPE(E,char[]), _throwstr(E,__FILE__,__LINE__,__func__), \
|
||||||
printf("NONE\n")))
|
printf("\e[31m[%s:%d/%s] UNKNOWN ERROR\n",__FILE__,__LINE__,__func__)))
|
||||||
|
|
||||||
|
#define ifNthrow(PTR) if (!PTR) throw(ERR_NULLPTR)
|
||||||
|
#define ifNretN(PTR) if (!PTR) return NULL
|
||||||
|
#define ifNret(PTR) if (!PTR) return
|
||||||
@ -1,5 +1,3 @@
|
|||||||
#pragma once
|
|
||||||
|
|
||||||
#include "std.h"
|
#include "std.h"
|
||||||
#include "base_types.h"
|
#include "base_types.h"
|
||||||
|
|
||||||
|
|||||||
@ -17,3 +17,4 @@
|
|||||||
|
|
||||||
#define CHOOSE(B, Y, N) __builtin_choose_expr(B, Y, N)
|
#define CHOOSE(B, Y, N) __builtin_choose_expr(B, Y, N)
|
||||||
#define IFTYPE(X, T) __builtin_types_compatible_p(typeof(X), T)
|
#define IFTYPE(X, T) __builtin_types_compatible_p(typeof(X), T)
|
||||||
|
#define dbg(N) printf("\e[95m%d\n",N)
|
||||||
@ -1,12 +1,16 @@
|
|||||||
#include "base/std.h"
|
#include "base/base.h"
|
||||||
#include "base/base_types.h"
|
#include "tests/tests.h"
|
||||||
#include "base/errors.h"
|
#include "Autoarr/Autoarr.h"
|
||||||
#include "base/Autoarr.h"
|
#include "SearchTree/SearchTree.h"
|
||||||
|
|
||||||
#define clrscr() printf("\e[1;1H\e[2J")
|
#define clrscr() printf("\e[1;1H\e[2J")
|
||||||
|
|
||||||
int main(){
|
int main(){
|
||||||
setlocale(LC_ALL, "en-US.Unicode");
|
setlocale(LC_ALL, "en-US.Unicode");
|
||||||
printf("\e[92mdtsod parser in c language!\e[94m\n");
|
printf("\e[92mdtsod parser in c language!\e[97m\n");
|
||||||
|
test_all();
|
||||||
|
Unitype a={Null,NULL};
|
||||||
|
STNode* node=STNode_create();
|
||||||
|
ST_push(node,"aboba", a);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "std.h"
|
#include "../base/base.h"
|
||||||
|
|
||||||
const wchar_t* slimak =
|
const wchar_t* slimak =
|
||||||
U" ▄▄▄ \n"
|
U" ▄▄▄ \n"
|
||||||
|
|||||||
6
DtsodC/src/tests/test_all.c
Normal file
6
DtsodC/src/tests/test_all.c
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
#include "tests.h"
|
||||||
|
|
||||||
|
void test_all(void){
|
||||||
|
test_autoarr();
|
||||||
|
test_searchtree();
|
||||||
|
}
|
||||||
@ -1,8 +1,8 @@
|
|||||||
#include "tests.h"
|
#include "tests.h"
|
||||||
#include "../base/Autoarr.h"
|
#include "../Autoarr/Autoarr.h"
|
||||||
|
|
||||||
void ardesc(Autoarr* ar){
|
void ardesc(Autoarr* ar){
|
||||||
printf("AUTOARR:%lu\n"
|
printf("\e[94m AUTOARR:%lu\n"
|
||||||
" type: %s\n"
|
" type: %s\n"
|
||||||
" max_block_count: %u\n"
|
" max_block_count: %u\n"
|
||||||
" curr_block_count: %u\n"
|
" curr_block_count: %u\n"
|
||||||
@ -23,18 +23,21 @@ void ardesc(Autoarr* ar){
|
|||||||
void fillar(Autoarr* ar){
|
void fillar(Autoarr* ar){
|
||||||
for (uint16 i=0;i<ar->max_length;i++)
|
for (uint16 i=0;i<ar->max_length;i++)
|
||||||
Autoarr_add_uint16(ar,i);
|
Autoarr_add_uint16(ar,i);
|
||||||
ardesc(ar);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void printar(Autoarr* ar){
|
void printar(Autoarr* ar){
|
||||||
for (uint16 i=0;i<ar->max_length;i++)
|
for (uint16 i=0;i<ar->max_length;i++)
|
||||||
printf("%u ", Autoarr_get_uint16(&ar,i));
|
printf("%u ", Autoarr_get_uint16(ar,i));
|
||||||
}
|
}
|
||||||
|
|
||||||
void testar(){
|
void test_autoarr(){
|
||||||
|
printf("\e[96m------------[test_autoarr]-------------\n");
|
||||||
Autoarr ar=Autoarr_create(10,16,UInt16);
|
Autoarr ar=Autoarr_create(10,16,UInt16);
|
||||||
|
printf("\e[92m autoarr created\n\e[90m");
|
||||||
fillar(&ar);
|
fillar(&ar);
|
||||||
printar(&ar);
|
printar(&ar);
|
||||||
Autoarr_free(&ar);
|
printf("\n\e[92m autoarr filled up\n");
|
||||||
ardesc(&ar);
|
ardesc(&ar);
|
||||||
|
Autoarr_clear(&ar);
|
||||||
|
printf("\e[92m autoarr cleared\n");
|
||||||
}
|
}
|
||||||
|
|||||||
23
DtsodC/src/tests/test_searchtree.c
Normal file
23
DtsodC/src/tests/test_searchtree.c
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
#include "tests.h"
|
||||||
|
#include "../SearchTree/SearchTree.h"
|
||||||
|
|
||||||
|
void printn(STNode* node){
|
||||||
|
printf("\e[94m STNode: %lu\n"
|
||||||
|
" branches: %p\n"
|
||||||
|
" value.type: %s\n"
|
||||||
|
" value.ptr: %p\n",
|
||||||
|
sizeof(STNode),
|
||||||
|
node->branches,
|
||||||
|
typename(node->value.type),
|
||||||
|
node->value.ptr
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
void test_searchtree(){
|
||||||
|
printf("\e[96m-----------[test_searchtree]-----------\n");
|
||||||
|
STNode* node=STNode_create();
|
||||||
|
printf("\e[92m node created\n");
|
||||||
|
printn(node);
|
||||||
|
STNode_free(node);
|
||||||
|
printf("\e[92m node deleted\n");
|
||||||
|
}
|
||||||
@ -3,3 +3,6 @@
|
|||||||
#include "../base/std.h"
|
#include "../base/std.h"
|
||||||
|
|
||||||
void test_autoarr(void);
|
void test_autoarr(void);
|
||||||
|
void test_searchtree(void);
|
||||||
|
|
||||||
|
void test_all(void);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user