From f73586a28d0bfbcdb6c48b6f40bef445b1cff696 Mon Sep 17 00:00:00 2001 From: PreacherDHM Date: Tue, 28 Jan 2025 13:36:01 -0800 Subject: [PATCH] fixed testing --- CMakeLists.txt | 2 +- includes/tart.h | 4 +-- source/CMakeLists.txt | 7 ++-- source/{tart.c => tart.cpp} | 10 +++--- testing/main.cpp | 2 +- testing/test_tart.cpp | 68 ++++++++++++++++++++----------------- 6 files changed, 51 insertions(+), 42 deletions(-) rename source/{tart.c => tart.cpp} (80%) diff --git a/CMakeLists.txt b/CMakeLists.txt index 66d7ed6..a0d3b83 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -8,7 +8,7 @@ set( CMAKE_C_STANDARD 11) set( CMAKE_C_STANDARD_REQUIRED ON) #set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/bin/libs) -#set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/bin) +set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/bin) set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/bin) set( CMAKE_COLOR_MAKEFILE ON) diff --git a/includes/tart.h b/includes/tart.h index a6dac63..f1f198f 100644 --- a/includes/tart.h +++ b/includes/tart.h @@ -72,8 +72,8 @@ struct tart_window { tart_byte buffer_count; }; -struct tart_buffer tart_create_buffer(tart_id, struct tart_vec2, struct tart_vec2); -struct tart_cell tart_create_cell(char, tart_byte, struct tart_rgb, struct tart_rgb); +struct tart_buffer tart_create_buffer(tart_id id, struct tart_vec2 size, struct tart_vec2 position); +struct tart_cell tart_create_cell(char display, tart_byte style, struct tart_rgb foreground, struct tart_rgb background); tart_byte tart_add_buffer(struct tart_window*, struct tart_buffer); tart_byte tart_set_buffer(struct tart_window*, struct tart_buffer, tart_byte); diff --git a/source/CMakeLists.txt b/source/CMakeLists.txt index 717090a..9ceee39 100644 --- a/source/CMakeLists.txt +++ b/source/CMakeLists.txt @@ -1,6 +1,9 @@ project(TartLib VERSION 0.1) +set( CMAKE_STATIC_LIBRARY_PREFIX "") + set(Lib_SOURCES - tart.c + tart.cpp ) -add_library(${PROJECT_NAME} STATIC tart.c) + +add_library(${PROJECT_NAME} STATIC tart.cpp) target_include_directories(${PROJECT_NAME} BEFORE PUBLIC "../includes/") diff --git a/source/tart.c b/source/tart.cpp similarity index 80% rename from source/tart.c rename to source/tart.cpp index 205abef..69d3e2e 100644 --- a/source/tart.c +++ b/source/tart.cpp @@ -1,17 +1,17 @@ -#include "tart.h" +#include "../includes/tart.h" #include struct tart_cell tart_test() { - return {{0,0,0}, {0,0,0}, 0, 't'}; + return (struct tart_cell){{0,0,0}, {0,0,0}, 0, 't'}; } struct tart_buffer tart_create_buffer(tart_id id, struct tart_vec2 size, struct tart_vec2 position) { - int cell_count = position.x * position.y; - struct tart_cell* cells = malloc(sizeof(struct tart_cell[cell_count])); + unsigned int cell_count = position.x * position.y; + struct tart_cell* cells = (struct tart_cell*)malloc(sizeof(struct tart_cell[cell_count])); struct tart_buffer buf = {cell_count,0,id,size,position,0}; return buf; } struct tart_cell tart_create_cell(char display, tart_byte style, struct tart_rgb foreground, struct tart_rgb background) { - struct tart_cell b = {{0,0,0}, {0,0,0}, 0, 't'}; + struct tart_cell b = {foreground, background, style, display}; return b; } tart_byte tart_add_buffer(struct tart_window* window, struct tart_buffer buffer) { diff --git a/testing/main.cpp b/testing/main.cpp index a42dae1..c0de5b5 100644 --- a/testing/main.cpp +++ b/testing/main.cpp @@ -3,5 +3,5 @@ int main (int argc, char *argv[]) { INSTALLSHELF; tart_run(&__pickle_shelf__); - return 0; + return PICKLESHELF; } diff --git a/testing/test_tart.cpp b/testing/test_tart.cpp index f1caa46..95976bc 100644 --- a/testing/test_tart.cpp +++ b/testing/test_tart.cpp @@ -1,5 +1,5 @@ #include "test_tart.h" -#include "tart.h" +#include "../includes/tart.h" bool rgb_test(struct tart_rgb* lhs, struct tart_rgb* rhs) { if(lhs->r != rhs->r) {return false;} if(lhs->g != rhs->g) {return false;} @@ -18,45 +18,51 @@ void tart_run(struct pickle_shelf* shelf) { CREATEJAR(tart_objects_test); PICKLE(Test_create_buffer) { - tart_buffer buffer_correct = {0,0,25,{20,20},{0,0}, 0}; - //tart_buffer buffer_test = tart_create_buffer(25,{20,20},{0,0}); + struct tart_buffer buffer_correct = {0,0,25,{20,20},{0,0}, 0}; + struct tart_buffer buffer_test = tart_create_buffer(25,{20,20},{0,0}); - //if(DIFFERENT(buffer_correct.cell_count,buffer_test.cell_count)) - // ASSERT("Cell count not the same.",false); - //if(DIFFERENT(buffer_correct.layer,buffer_test.layer)) - // ASSERT("Layers not the same.",false); - //if(DIFFERENT(buffer_correct.id,buffer_test.id)) - // ASSERT("Ids are not the same.",false); - //if(DIFFERENT(buffer_correct.size.x,buffer_test.size.x)) - // ASSERT("size.x is not the same",false); - //if(DIFFERENT(buffer_correct.size.y,buffer_test.size.y)) - // ASSERT("size.y is not the same",false); - //if(DIFFERENT(buffer_correct.position.x,buffer_test.position.x)) - // ASSERT("position.x is not the same.",false); - //if(DIFFERENT(buffer_correct.position.y,buffer_test.position.y)) - // ASSERT("position.y is not the same.",false); - //if(DIFFERENT(&buffer_correct.cells,&buffer_test.cells)) - // ASSERT("cells address not the same should be 0",false); + if(DIFFERENT(buffer_correct.cell_count,buffer_test.cell_count)) + ASSERT("Cell count not the same.",false); + if(DIFFERENT(buffer_correct.layer,buffer_test.layer)) + ASSERT("Layers not the same.",false); + if(DIFFERENT(buffer_correct.id,buffer_test.id)) + ASSERT("Ids are not the same.",false); + if(DIFFERENT(buffer_correct.size.x,buffer_test.size.x)) + ASSERT("size.x is not the same",false); + if(DIFFERENT(buffer_correct.size.y,buffer_test.size.y)) + ASSERT("size.y is not the same",false); + if(DIFFERENT(buffer_correct.position.x,buffer_test.position.x)) + ASSERT("position.x is not the same.",false); + if(DIFFERENT(buffer_correct.position.y,buffer_test.position.y)) + ASSERT("position.y is not the same.",false); ASSERT("GOOD",true); }(); PICKLE(Test_create_cell) { struct tart_rgb b = {80,80,80}; - struct tart_rgb f = {40,40,40}; - struct tart_cell cell_correct = {f, b, '1', 't'}; - struct tart_cell cell_test = tart_create_cell('f', 0x90, {0,0,0}, {0,0,0}); //tart_create_cell('t','1',f,b); - //if(rgb_test(&cell_correct.foreground, &cell_test.foreground)) - // ASSERT("Forground dose not match.",false); - //if(rgb_test(&cell_correct.background, &cell_test.background)) - // ASSERT("background dose not match.",false); - //if(DIFFERENT(cell_correct.style, cell_test.style)) - // ASSERT("style dose not match.",false); - //if(DIFFERENT(cell_correct.display, cell_test.display)) - // ASSERT("display dose not match.",false); + struct tart_rgb f = {80,80,80}; + struct tart_cell cell_correct = {f, b, '1', 'f'}; + struct tart_cell cell_test = tart_create_cell('f', '1', f, b); + if(!rgb_test(&cell_correct.foreground, &cell_test.foreground)) + ASSERT("Forground dose not match.",false); + if(!rgb_test(&cell_correct.background, &cell_test.background)) + ASSERT("background dose not match.",false); + if(DIFFERENT(cell_correct.style, cell_test.style)) + ASSERT("style dose not match.",false); + if(DIFFERENT(cell_correct.display, cell_test.display)) + ASSERT("display dose not match.",false); ASSERT("GOOD",true); }(); + + PICKLE(Test_Add_buffer) { + struct tart_buffer buffer = tart_create_buffer(10, {10,20}, {0,0}); + + ASSERT("GOOD",true); + }(); + ADDPICKLE(tart_objects_test,Test_create_buffer); ADDPICKLE(tart_objects_test,Test_create_cell); - shelf = &__pickle_shelf__; + PUTJARONSHELF(tart_objects_test); + *shelf = __pickle_shelf__; }