fixed testing

This commit is contained in:
2025-01-28 13:36:01 -08:00
parent caf148175b
commit f73586a28d
6 changed files with 51 additions and 42 deletions

View File

@@ -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)

View File

@@ -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);

View File

@@ -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/")

View File

@@ -1,17 +1,17 @@
#include "tart.h"
#include "../includes/tart.h"
#include <malloc.h>
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) {

View File

@@ -3,5 +3,5 @@
int main (int argc, char *argv[]) {
INSTALLSHELF;
tart_run(&__pickle_shelf__);
return 0;
return PICKLESHELF;
}

View File

@@ -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__;
}