added unit tests support

Signed-off-by: h4570 <sandro.sobczynski@gmail.com>
This commit is contained in:
h4570
2021-05-25 19:18:21 +02:00
parent 10b275055c
commit 8b0233a45d
6 changed files with 18037 additions and 0 deletions
+3
View File
@@ -0,0 +1,3 @@
.vscode/
bin/**
fonts/**
+41
View File
@@ -0,0 +1,41 @@
EE_BIN = unit_tests.elf
TYRA_DIR = ./../engine
PCSX2_PATH = /mnt/c/Program\ Files\ \(x86\)/PCSX2/pcsx2.exe
WSL_TYRA_PATH = \\\\wsl$$\\PS2-DEV\\repos\\tyra
EE_OBJS = \
tests/utils/math.o \
main.o
EE_LIBS = -ltyra
all: $(EE_BIN)
$(EE_STRIP) --strip-all $(EE_BIN)
mv $(EE_BIN) bin/$(EE_BIN)
rm $(EE_OBJS)
rebuild-engine:
cd $(TYRA_DIR) && make clean && make
clean:
rm -f $(EE_OBJS)
run: $(EE_BIN)
killall -v ps2client || true
ps2client reset
ps2client reset
$(EE_STRIP) --strip-all $(EE_BIN)
mv $(EE_BIN) bin/$(EE_BIN)
rm $(EE_OBJS)
cd bin/ && ps2client execee host:$(EE_BIN)
run-pcsx2:
taskkill.exe /f /t /im pcsx2.exe || true
$(PCSX2_PATH) --elf=$(WSL_TYRA_PATH)\\src\\unit_tests\\bin\\unit_tests.elf
show:
cat bin/test-result.txt
include $(TYRA_DIR)/Makefile.pref
File diff suppressed because it is too large Load Diff
+28
View File
@@ -0,0 +1,28 @@
/*
# ______ ____ ___
# | \/ ____| |___|
# | | | \ | |
#-----------------------------------------------------------------------
# Copyright 2021, tyra - https://github.com/h4570/tyra
# Licenced under Apache License 2.0
# Sandro Sobczyński <sandro.sobczynski@gmail.com>
*/
// To run unit tests
// 1. Make sure that your $(PCSX2_PATH) and $(WSL_TYRA_PATH) Makefile variables are correct
// 2. make && make run-pcsx2 && make show
// 3. Click 'X' in PCSX2 when screen will be on memory card selection stage
// 4. Voila :)
const int CUSTOM_ARGC = 5;
char const *CUSTOM_ARGV[] = {
"",
"--reporter",
"console",
"--out",
"test-result.txt"};
#define CATCH_CONFIG_MAIN
#define CATCH_CONFIG_NO_POSIX_SIGNALS
#include "catch.hpp"
+22
View File
@@ -0,0 +1,22 @@
/*
# ______ ____ ___
# | \/ ____| |___|
# | | | \ | |
#-----------------------------------------------------------------------
# Copyright 2021, tyra - https://github.com/h4570/tyra
# Licenced under Apache License 2.0
# Sandro Sobczyński <sandro.sobczynski@gmail.com>
*/
#include <catch.hpp>
#include <utils/math.hpp>
SCENARIO("min(a,b) greater 'a' should return 'b'", "[math.cpp]")
{
REQUIRE(Math::min(10, 5) == 5);
}
SCENARIO("min(a,b) greater 'b' should return 'a'", "[math.cpp]")
{
REQUIRE(Math::min(-5, 5) == -5);
}