From 654bb8b09dd90c12c3a51ffdce800b2255b753b5 Mon Sep 17 00:00:00 2001 From: FreeArtMan Date: Sun, 12 May 2019 12:46:02 +0100 Subject: Moved everything to C+. First test works --- test.c | 71 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 68 insertions(+), 3 deletions(-) (limited to 'test.c') diff --git a/test.c b/test.c index 9bb8f31..c4dc609 100644 --- a/test.c +++ b/test.c @@ -1,6 +1,8 @@ #include #include +#include +#include "__cpp.h" #include "buf.h" #include "debug.h" @@ -37,45 +39,108 @@ void print_s(char *str, int sz) int main() { + /* bbuf *b1=NULL, *b2=NULL; int ret; + */ + Buf *b1=NULL, *b2=NULL; + int rc; printf("Start test\n"); + /* bbuf_free(b1); + */ + delete b1; printf("Create new buffer\n"); + /* b1 = bbuf_new(BUF_SIZE_1); bbuf_free(b1); + */ + + b1 = new Buf(BUF_SIZE_1); + delete b1; printf("Copy buffer\n"); + /* b1 = bbuf_new(BUF_SIZE_1); b2 = bbuf_copy(b1); bbuf_free(b1); bbuf_free(b2); - + */ + b1 = new Buf(BUF_SIZE_1); + b2 = b1->copy(); + delete b1; b1=NULL; + delete b2; b2=NULL; + printf("Get buffer\n"); char name1[] = "Lets get buffer and print it out"; char *get_val = NULL; int get_size; + /* b1 = bbuf_new(BUF_SIZE_1); B(bbuf_set(b1,name1,strlen(name1))); B(bbuf_get(b1,&get_val,&get_size)); print_s(get_val,get_size);printf("\n"); + */ + b1 = new Buf(BUF_SIZE_1); + B(b1->set(name1, strlen(name1))); + B(b1->get(&get_val, &get_size)); + print_s(get_val, get_size);printf("\n"); + + /* b2 = bbuf_copy(b1); B(bbuf_get(b2,&get_val,&get_size)); print_s(get_val,get_size);printf("\n"); + */ + b2 = b1->copy(); + B(b2->get(&get_val,&get_size)); + print_s(get_val,get_size);printf("\n"); + /* bbuf_free(b1); bbuf_free(b2); - + */ + delete b1; + delete b2; + printf("Realloc buffer\n"); + /* b1 = bbuf_new(BUF_SIZE_1); B(bbuf_realloc(b1,BUF_SIZE_2)); bbuf_free(b1); - + */ + b1 = new Buf(BUF_SIZE_1); + b1->realloc(BUF_SIZE_2); + delete b1; + + + printf("Concat 2 strings"); + b1 = new Buf(8); + b2 = new Buf(8); + char n1[] = "Name"; + char n2[] = "File"; + char n3[] = "Nothing"; + + B(b1->set(n1)); + B(b2->set(n2)); + + b1->print(); printf("\n"); + b2->print(); printf("\n"); + + printf("%d:",b1->concat(b2)); + b1->print(); printf("\n"); + + B(b2->set(n3)); + printf("%d:",b1->concat(b2)); + b1->print(); printf("\n"); + + delete b1; + delete b2; + printf("End test\n"); return 0; -- cgit v1.2.3