#include "test_tart.h" #include "Pickler.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;} if(lhs->b != rhs->b) {return false;} return true; } bool vec2_test(struct tart_vec2* lhs, struct tart_vec2* rhs) { if(lhs->x != rhs->x) {return false;} if(lhs->y != rhs->y) {return false;} return true; } void tart_run(struct pickle_shelf* shelf) { pickle_shelf __pickle_shelf__ = *shelf; CREATEJAR(tart_objects_test); PICKLE(Test_create_buffer) { struct tart_vec2 size = {25,25}; struct tart_vec2 position = {0,0}; int data_count = (size.x*size.y) * TART_CELL_DATA_SIZE; unsigned int cell_count = (size.x * size.y); struct tart_buffer buffer_correct = {cell_count,0,25,size,position,0}; struct tart_buffer buffer_test = tart_create_buffer(25,size,position); 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.cell_count,buffer_test.cell_count)) ASSERT("data_counts are not the same.",false); ASSERT("GOOD",true); }(); PICKLE(Test_create_cell) { #ifdef TART_RGB_COLOR struct tart_rgb b = {80,80,80}; 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); #else tart_byte f = 20; tart_byte b = 40; struct tart_cell cell_correct = {f, b, '1', 'f'}; struct tart_cell cell_test = tart_create_cell('f', '1', f, b); if(DIFFERENT(cell_correct.foreground, cell_test.foreground)) ASSERT("Forground dose not match.",false); if(DIFFERENT(cell_correct.background, cell_test.background)) ASSERT("background dose not match.",false); #endif 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_create_window) { struct tart_buffer buffer = tart_create_buffer(10, {10,20}, {0,0}); struct tart_window window = tart_create_window(); for(int i = 0; i < 0xFF + 1; i++) { if(DIFFERENT(window.buffers[i].id, 0)) ASSERT("buffer not same", false); } ASSERT("GOOD", true); }(); PICKLE(Test_add_buffer) { struct tart_buffer buffer = tart_create_buffer(10, {10,20}, {0,0}); struct tart_window window = tart_create_window(); tart_add_buffer(&window, buffer); if(SAME(window.buffer_count, 0)) ASSERT("index has not indexed", false); if(DIFFERENT(window.buffers[0].id, buffer.id)) ASSERT("buffer not same", false); ASSERT("GOOD", true); }(); PICKLE(Test_set_buffer) { struct tart_buffer buffer = tart_create_buffer(10, {10,20}, {0,0}); struct tart_window window = tart_create_window(); tart_set_buffer(&window, buffer, 0); if(DIFFERENT(window.buffers[0].id, buffer.id)) ASSERT("buffer not same", false); ASSERT("GOOD", true); }(); PICKLE(Test_get_buffer) { struct tart_buffer buffer = tart_create_buffer(10, {10,20}, {0,0}); struct tart_window window = tart_create_window(); tart_set_buffer(&window, buffer, 0); if(DIFFERENT(tart_get_buffer(&window, 0)->id, buffer.id)) ASSERT("buffer not same", false); ASSERT("GOOD", true); }(); PICKLE(Test_set_cell) { #ifdef TART_RGB_COLORS tart_rgb foreground = {90,90,90}; tart_rgb background = {80,80,80}; #else tart_byte foreground = 9; tart_byte background = 8; #endif struct tart_cell cell = tart_create_cell('0',10,foreground, background); struct tart_buffer buffer = tart_create_buffer(10, {10,20}, {10,20}); struct tart_window window = tart_create_window(); tart_set_cell(&buffer, cell, 0); if(DIFFERENT(buffer.cells[0].display, cell.display)) ASSERT("buffer not same", false); ASSERT("GOOD", true); }(); PICKLE(Test_get_cell) { #ifdef TART_RGB_COLORS tart_rgb foreground = {90,90,90}; tart_rgb background = {80,80,80}; #else tart_byte foreground = 9; tart_byte background = 8; #endif struct tart_cell cell = tart_create_cell('0',10,foreground, background); struct tart_buffer buffer = tart_create_buffer(10, {10,20}, {10,20}); struct tart_window window = tart_create_window(); tart_set_cell(&buffer, cell, 0); if(DIFFERENT(tart_get_cell(&buffer,0)->display, cell.display)) ASSERT("buffer not same", false); ASSERT("GOOD", true); }(); ADDPICKLE(tart_objects_test,Test_create_buffer); ADDPICKLE(tart_objects_test,Test_create_cell); ADDPICKLE(tart_objects_test,Test_create_buffer); ADDPICKLE(tart_objects_test,Test_add_buffer); ADDPICKLE(tart_objects_test,Test_set_buffer); ADDPICKLE(tart_objects_test,Test_get_buffer); ADDPICKLE(tart_objects_test,Test_set_cell); ADDPICKLE(tart_objects_test,Test_get_cell); PUTJARONSHELF(tart_objects_test); *shelf = __pickle_shelf__; }