Now off catch2 and on my own testing fuc2.
This commit is contained in:
parent
4f3fa59793
commit
1d11c8b162
10 changed files with 177 additions and 98 deletions
4
Makefile
4
Makefile
|
|
@ -26,7 +26,7 @@ tracy_build:
|
||||||
meson compile -j 10 -C builddir
|
meson compile -j 10 -C builddir
|
||||||
|
|
||||||
test: build
|
test: build
|
||||||
./builddir/runtests
|
./builddir/fuc2it
|
||||||
|
|
||||||
run: build test
|
run: build test
|
||||||
ifeq '$(OS)' 'Windows_NT'
|
ifeq '$(OS)' 'Windows_NT'
|
||||||
|
|
@ -49,7 +49,7 @@ clean:
|
||||||
meson compile --clean -C builddir
|
meson compile --clean -C builddir
|
||||||
|
|
||||||
debug_test: build
|
debug_test: build
|
||||||
gdb --nx -x .gdbinit --ex run --args builddir/runtests -e
|
gdb --nx -x .gdbinit --ex run --args builddir/fuc2it -e
|
||||||
|
|
||||||
win_installer:
|
win_installer:
|
||||||
powershell 'start "C:\Program Files (x86)\solicus\InstallForge\bin\ifbuilderenvx86.exe" scripts\win_installer.ifp'
|
powershell 'start "C:\Program Files (x86)\solicus\InstallForge\bin\ifbuilderenvx86.exe" scripts\win_installer.ifp'
|
||||||
|
|
|
||||||
11
meson.build
11
meson.build
|
|
@ -3,7 +3,7 @@
|
||||||
# HEY BUG: when you have a . spec in a LEL it doesn't work on text
|
# HEY BUG: when you have a . spec in a LEL it doesn't work on text
|
||||||
|
|
||||||
project('lel-guecs', 'cpp',
|
project('lel-guecs', 'cpp',
|
||||||
version: '0.7.3',
|
version: '0.7.4',
|
||||||
default_options: [
|
default_options: [
|
||||||
'cpp_std=c++23',
|
'cpp_std=c++23',
|
||||||
'cpp_args=-D_GLIBCXX_DEBUG=1 -D_GLIBCXX_DEBUG_PEDANTIC=1',
|
'cpp_args=-D_GLIBCXX_DEBUG=1 -D_GLIBCXX_DEBUG_PEDANTIC=1',
|
||||||
|
|
@ -51,7 +51,7 @@ elif build_machine.system() == 'darwin'
|
||||||
]
|
]
|
||||||
endif
|
endif
|
||||||
|
|
||||||
catch2 = subproject('catch2').get_variable('catch2_with_main_dep')
|
fuc2 = subproject('fuc2').get_variable('fuc2_dep')
|
||||||
fmt = subproject('fmt').get_variable('fmt_dep')
|
fmt = subproject('fmt').get_variable('fmt_dep')
|
||||||
json = subproject('nlohmann_json').get_variable('nlohmann_json_dep')
|
json = subproject('nlohmann_json').get_variable('nlohmann_json_dep')
|
||||||
freetype2 = subproject('freetype2').get_variable('freetype_dep')
|
freetype2 = subproject('freetype2').get_variable('freetype_dep')
|
||||||
|
|
@ -117,19 +117,20 @@ lel_guecs_sfml_dep = declare_dependency(
|
||||||
link_with: lel_guecs_sfml_lib,
|
link_with: lel_guecs_sfml_lib,
|
||||||
include_directories: lel_guecs_inc)
|
include_directories: lel_guecs_inc)
|
||||||
|
|
||||||
executable('runtests', [
|
executable('fuc2it', [
|
||||||
|
'tests/guecs.cpp',
|
||||||
'tests/lel.cpp',
|
'tests/lel.cpp',
|
||||||
|
'tests/main.cpp',
|
||||||
'tests/shaders.cpp',
|
'tests/shaders.cpp',
|
||||||
'tests/sound.cpp',
|
'tests/sound.cpp',
|
||||||
'tests/textures.cpp',
|
'tests/textures.cpp',
|
||||||
'tests/guecs.cpp',
|
|
||||||
],
|
],
|
||||||
cpp_args: cpp_args,
|
cpp_args: cpp_args,
|
||||||
link_args: link_args,
|
link_args: link_args,
|
||||||
override_options: exe_defaults,
|
override_options: exe_defaults,
|
||||||
include_directories: lel_guecs_inc,
|
include_directories: lel_guecs_inc,
|
||||||
link_with: [lel_guecs_lib, lel_guecs_sfml_lib],
|
link_with: [lel_guecs_lib, lel_guecs_sfml_lib],
|
||||||
dependencies: dependencies + [catch2])
|
dependencies: dependencies + [fuc2])
|
||||||
|
|
||||||
executable('clicker_game', [
|
executable('clicker_game', [
|
||||||
'demos/clicker_game.cpp',
|
'demos/clicker_game.cpp',
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,20 @@
|
||||||
#include <catch2/catch_test_macros.hpp>
|
|
||||||
#include <fmt/core.h>
|
#include <fmt/core.h>
|
||||||
#include "guecs/ui.hpp"
|
#include "guecs/ui.hpp"
|
||||||
#include <fmt/xchar.h>
|
#include <fmt/xchar.h>
|
||||||
|
#include <fuc2/testing.hpp>
|
||||||
|
|
||||||
using namespace guecs;
|
using namespace guecs;
|
||||||
|
using namespace fuc2;
|
||||||
|
|
||||||
TEST_CASE("prototype one gui", "[ecs-gui]") {
|
namespace guecs_tests {
|
||||||
|
void test_prototype() {
|
||||||
// accidentally gutted, will recover later
|
// accidentally gutted, will recover later
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fuc2::Set TESTS{
|
||||||
|
.name="GUECS tests (empty!)",
|
||||||
|
.tests={
|
||||||
|
{"test_prototype", test_prototype},
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,12 @@
|
||||||
#include "guecs/lel.hpp"
|
#include "guecs/lel.hpp"
|
||||||
#include <catch2/catch_test_macros.hpp>
|
|
||||||
#include <fmt/core.h>
|
#include <fmt/core.h>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <fuc2/testing.hpp>
|
||||||
|
|
||||||
TEST_CASE("test basic ops", "[lel]") {
|
using namespace fuc2;
|
||||||
|
|
||||||
|
namespace lel_tests {
|
||||||
|
void test_basic_ops() {
|
||||||
lel::Parser parser(0, 0, 500, 500);
|
lel::Parser parser(0, 0, 500, 500);
|
||||||
|
|
||||||
bool good = parser.parse(
|
bool good = parser.parse(
|
||||||
|
|
@ -12,7 +15,7 @@ TEST_CASE("test basic ops", "[lel]") {
|
||||||
"[ >label2 | _ | .test3]"
|
"[ >label2 | _ | .test3]"
|
||||||
"[ =message | buttons | test4]");
|
"[ =message | buttons | test4]");
|
||||||
|
|
||||||
REQUIRE(good);
|
CHECK(good);
|
||||||
|
|
||||||
for(size_t rowcount = 0; rowcount < parser.grid.size(); rowcount++) {
|
for(size_t rowcount = 0; rowcount < parser.grid.size(); rowcount++) {
|
||||||
auto& row = parser.grid[rowcount];
|
auto& row = parser.grid[rowcount];
|
||||||
|
|
@ -20,42 +23,50 @@ TEST_CASE("test basic ops", "[lel]") {
|
||||||
for(size_t colcount = 0; colcount < row.size(); colcount++) {
|
for(size_t colcount = 0; colcount < row.size(); colcount++) {
|
||||||
auto &name = row[colcount];
|
auto &name = row[colcount];
|
||||||
if(name == "_") {
|
if(name == "_") {
|
||||||
REQUIRE(!parser.cells.contains(name));
|
CHECK(!parser.cells.contains(name));
|
||||||
} else if(name == "_MAIN") {
|
} else if(name == "_MAIN") {
|
||||||
// it's the main cell which covers the whole area
|
// it's the main cell which covers the whole area
|
||||||
auto &cell = parser.cells.at(name);
|
auto &cell = parser.cells.at(name);
|
||||||
REQUIRE(cell.row == 0);
|
CHECK(cell.row == 0);
|
||||||
REQUIRE(cell.col == 0);
|
CHECK(cell.col == 0);
|
||||||
REQUIRE(cell.x == parser.grid_x);
|
CHECK(cell.x == parser.grid_x);
|
||||||
REQUIRE(cell.y == parser.grid_y);
|
CHECK(cell.y == parser.grid_y);
|
||||||
REQUIRE(cell.w == parser.grid_w);
|
CHECK(cell.w == parser.grid_w);
|
||||||
REQUIRE(cell.h == parser.grid_h);
|
CHECK(cell.h == parser.grid_h);
|
||||||
} else {
|
} else {
|
||||||
auto &cell = parser.cells.at(name);
|
auto &cell = parser.cells.at(name);
|
||||||
REQUIRE(cell.row == int(rowcount));
|
CHECK(cell.row == int(rowcount));
|
||||||
REQUIRE(cell.col == int(colcount));
|
CHECK(cell.col == int(colcount));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
REQUIRE(parser.cells.size() == 11);
|
CHECK(parser.cells.size() == 11);
|
||||||
REQUIRE(parser.cells.at("label2").right == true);
|
CHECK(parser.cells.at("label2").right == true);
|
||||||
REQUIRE(parser.cells.at("text1").expand == true);
|
CHECK(parser.cells.at("text1").expand == true);
|
||||||
REQUIRE(parser.cells.at("text1").w == 300);
|
CHECK(parser.cells.at("text1").w == 300);
|
||||||
REQUIRE(parser.cells.at("text1").h == 300);
|
CHECK(parser.cells.at("text1").h == 300);
|
||||||
REQUIRE(parser.cells.at("people").expand == false);
|
CHECK(parser.cells.at("people").expand == false);
|
||||||
REQUIRE(parser.cells.at("message").expand == false);
|
CHECK(parser.cells.at("message").expand == false);
|
||||||
REQUIRE(parser.cells.at("message").center == true);
|
CHECK(parser.cells.at("message").center == true);
|
||||||
|
|
||||||
for(auto& [name, cell] : parser.cells) {
|
for(auto& [name, cell] : parser.cells) {
|
||||||
REQUIRE(cell.w > 0);
|
CHECK(cell.w > 0);
|
||||||
REQUIRE(cell.h > 0);
|
CHECK(cell.h > 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
auto hit = parser.hit(10, 10);
|
auto hit = parser.hit(10, 10);
|
||||||
REQUIRE(*hit == "label_1");
|
CHECK(*hit == "label_1");
|
||||||
|
|
||||||
auto nohit = parser.hit(1000, 1000);
|
auto nohit = parser.hit(1000, 1000);
|
||||||
REQUIRE(!nohit);
|
CHECK(!nohit);
|
||||||
REQUIRE(nohit == std::nullopt);
|
CHECK(nohit == std::nullopt);
|
||||||
|
}
|
||||||
|
|
||||||
|
fuc2::Set TESTS{
|
||||||
|
.name="lel parser tests",
|
||||||
|
.tests={
|
||||||
|
{"test_basic_ops", test_basic_ops},
|
||||||
|
}
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
31
tests/main.cpp
Normal file
31
tests/main.cpp
Normal file
|
|
@ -0,0 +1,31 @@
|
||||||
|
#include <fuc2/run.hpp>
|
||||||
|
|
||||||
|
// you can also place these into a .hpp you include if
|
||||||
|
// they're too numerous to manage
|
||||||
|
namespace lel_tests {
|
||||||
|
extern fuc2::Set TESTS;
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace guecs_tests {
|
||||||
|
extern fuc2::Set TESTS;
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace shader_tests {
|
||||||
|
extern fuc2::Set TESTS;
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace sound_tests {
|
||||||
|
extern fuc2::Set TESTS;
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace texture_tests {
|
||||||
|
extern fuc2::Set TESTS;
|
||||||
|
}
|
||||||
|
|
||||||
|
int main(int argc, char* argv[]) {
|
||||||
|
run(lel_tests::TESTS);
|
||||||
|
run(guecs_tests::TESTS);
|
||||||
|
run(shader_tests::TESTS);
|
||||||
|
run(sound_tests::TESTS);
|
||||||
|
run(texture_tests::TESTS);
|
||||||
|
}
|
||||||
|
|
@ -1,26 +1,36 @@
|
||||||
#include <catch2/catch_test_macros.hpp>
|
|
||||||
#include <fmt/core.h>
|
#include <fmt/core.h>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include "guecs/sfml/shaders.hpp"
|
#include "guecs/sfml/shaders.hpp"
|
||||||
|
#include <fuc2/testing.hpp>
|
||||||
|
|
||||||
|
using namespace fuc2;
|
||||||
using namespace fmt;
|
using namespace fmt;
|
||||||
|
|
||||||
TEST_CASE("shader loading/init works", "[shaders]") {
|
namespace shader_tests {
|
||||||
|
void test_shader_loading() {
|
||||||
shaders::init();
|
shaders::init();
|
||||||
int version = shaders::version();
|
int version = shaders::version();
|
||||||
|
|
||||||
std::shared_ptr<sf::Shader> ui_shader = shaders::get("ui_shader");
|
std::shared_ptr<sf::Shader> ui_shader = shaders::get("ui_shader");
|
||||||
auto other_test = shaders::get("ui_shader");
|
auto other_test = shaders::get("ui_shader");
|
||||||
|
|
||||||
REQUIRE(ui_shader != nullptr);
|
CHECK(ui_shader != nullptr);
|
||||||
REQUIRE(ui_shader == other_test);
|
CHECK(ui_shader == other_test);
|
||||||
REQUIRE(shaders::updated(version) == false);
|
CHECK(shaders::updated(version) == false);
|
||||||
|
|
||||||
int new_version = shaders::reload();
|
int new_version = shaders::reload();
|
||||||
REQUIRE(version != shaders::version());
|
CHECK(version != shaders::version());
|
||||||
REQUIRE(version != new_version);
|
CHECK(version != new_version);
|
||||||
REQUIRE(shaders::version() == new_version);
|
CHECK(shaders::version() == new_version);
|
||||||
REQUIRE(shaders::updated(version) == true);
|
CHECK(shaders::updated(version) == true);
|
||||||
version = new_version;
|
version = new_version;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fuc2::Set TESTS{
|
||||||
|
.name="shader tests",
|
||||||
|
.tests={
|
||||||
|
{"test_shader_loading", test_shader_loading},
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,14 +1,23 @@
|
||||||
#include <catch2/catch_test_macros.hpp>
|
|
||||||
#include <fmt/core.h>
|
#include <fmt/core.h>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include "guecs/sfml/sound.hpp"
|
#include "guecs/sfml/sound.hpp"
|
||||||
|
#include <fuc2/testing.hpp>
|
||||||
|
|
||||||
using namespace fmt;
|
using namespace fuc2;
|
||||||
|
|
||||||
TEST_CASE("test sound manager", "[sound]") {
|
namespace sound_tests {
|
||||||
|
void test_sound_manager() {
|
||||||
sound::init();
|
sound::init();
|
||||||
|
|
||||||
sound::play("blank");
|
sound::play("blank");
|
||||||
|
|
||||||
sound::play_at("blank", 0.1, 0.1, 0.1);
|
sound::play_at("blank", 0.1, 0.1, 0.1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fuc2::Set TESTS{
|
||||||
|
.name="sound manager tests",
|
||||||
|
.tests={
|
||||||
|
{"test_sound_manager", test_sound_manager},
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,15 +1,24 @@
|
||||||
#include <catch2/catch_test_macros.hpp>
|
|
||||||
#include <fmt/core.h>
|
#include <fmt/core.h>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include "guecs/sfml/textures.hpp"
|
#include "guecs/sfml/textures.hpp"
|
||||||
|
#include <fuc2/testing.hpp>
|
||||||
|
|
||||||
using namespace fmt;
|
using namespace fuc2;
|
||||||
|
|
||||||
TEST_CASE("test texture management", "[textures]") {
|
namespace texture_tests {
|
||||||
|
void test_texture_management() {
|
||||||
textures::init();
|
textures::init();
|
||||||
auto spider = textures::get("textures_test");
|
auto spider = textures::get("textures_test");
|
||||||
REQUIRE(spider.sprite != nullptr);
|
CHECK(spider.sprite != nullptr);
|
||||||
REQUIRE(spider.texture != nullptr);
|
CHECK(spider.texture != nullptr);
|
||||||
|
|
||||||
auto image = textures::load_image("assets/textures_test.png");
|
auto image = textures::load_image("assets/textures_test.png");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fuc2::Set TESTS{
|
||||||
|
.name="texture manager tests",
|
||||||
|
.tests={
|
||||||
|
{"test_texture_management", test_texture_management},
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,11 +0,0 @@
|
||||||
[wrap-file]
|
|
||||||
directory = Catch2-3.7.1
|
|
||||||
source_url = https://github.com/catchorg/Catch2/archive/v3.7.1.tar.gz
|
|
||||||
source_filename = Catch2-3.7.1.tar.gz
|
|
||||||
source_hash = c991b247a1a0d7bb9c39aa35faf0fe9e19764213f28ffba3109388e62ee0269c
|
|
||||||
source_fallback_url = https://github.com/mesonbuild/wrapdb/releases/download/catch2_3.7.1-1/Catch2-3.7.1.tar.gz
|
|
||||||
wrapdb_version = 3.7.1-1
|
|
||||||
|
|
||||||
[provide]
|
|
||||||
catch2 = catch2_dep
|
|
||||||
catch2-with-main = catch2_with_main_dep
|
|
||||||
9
wraps/fuc2.wrap
Normal file
9
wraps/fuc2.wrap
Normal file
|
|
@ -0,0 +1,9 @@
|
||||||
|
[wrap-git]
|
||||||
|
directory=fuc2-0.1.0
|
||||||
|
url=https://lcthw.dev/cpp/fuc2.git
|
||||||
|
revision=HEAD
|
||||||
|
depth=1
|
||||||
|
method=meson
|
||||||
|
|
||||||
|
[provide]
|
||||||
|
fuc2 = fuc2_dep
|
||||||
Loading…
Add table
Add a link
Reference in a new issue