added a test for term functions

This commit is contained in:
2025-01-29 14:46:08 -08:00
parent b3bee70aeb
commit 2a3a55c201
6 changed files with 44 additions and 8 deletions

View File

@@ -3,6 +3,7 @@
#ifdef __cplusplus
extern "C" {
#endif
#include "../source/term.h"
// #========================================================================#
// | PreacherDHM:TART
// |

View File

@@ -2,7 +2,8 @@
#include "../includes/tart.h"
#ifdef _WIN64
// if windows is defined.
#include <Windows.h>
struct tart_vec2 term_current_size() {
struct tart_vec2 ret;
@@ -19,10 +20,3 @@ struct tart_vec2 term_current_size() {
return ret;
}
#else
struct tart_vec2 term_current_size() {
struct tart_vec2 ret = {50,50};
return ret;
}
#endif

View File

@@ -4,6 +4,7 @@ set( CMAKE_CXX_STANDARD_REQUIRED ON)
set( SOURCES
main.cpp
test_tart.cpp
test_term.cpp
)
add_executable(${PROJECT_NAME} ${SOURCES} )

View File

@@ -1,7 +1,9 @@
#include "test_tart.h"
#include "test_term.h"
#include <Pickler.h>
int main (int argc, char *argv[]) {
INSTALLSHELF;
tart_run(&__pickle_shelf__);
term_run(&__pickle_shelf__);
return PICKLESHELF;
}

31
testing/test_term.cpp Normal file
View File

@@ -0,0 +1,31 @@
#include <Windows.h>
#include <iostream>
#include "test_term.h"
void term_run(struct pickle_shelf* shelf) {
struct pickle_shelf __pickle_shelf__ = *shelf; //start
CREATEJAR(Test_Term);
PICKLE(Test_get_window_size) {
CONSOLE_SCREEN_BUFFER_INFO csbi;
GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &csbi);
int columns = (unsigned int)(csbi.srWindow.Right - csbi.srWindow.Left + 1);
int rows = (unsigned int)(csbi.srWindow.Bottom - csbi.srWindow.Top + 1);
std::cout << "\n";
std::cout << term_current_size().x << "term_current_size()\n";
std::cout << columns << " columns\n";
if(term_current_size().x != columns)
ASSERT("current_size.x is not the same as columns", false);
if(term_current_size().y != rows)
ASSERT("current_size.y is not the same as rows", false);
ASSERT("GOOD", true);
}();
ADDPICKLE(Test_Term, Test_get_window_size);
PUTJARONSHELF(Test_Term);
*shelf = __pickle_shelf__; // end
}

7
testing/test_term.h Normal file
View File

@@ -0,0 +1,7 @@
#ifndef TEST_TERM_H
#define TEST_TERM_H
#include <tart.h>
#include <Pickler.h>
void term_run(struct pickle_shelf*);
#endif