A simple config loader test.

master
Zed A. Shaw 2 weeks ago
parent b8bb49df2c
commit 947ccbe180
  1. 2
      Makefile
  2. 1
      assets/enemies.json
  3. 7
      meson.build
  4. 18
      tests/config.cpp

@ -22,7 +22,7 @@ tracy_build:
meson compile -j 10 -C builddir
test: build
./builddir/runtests "[components]"
./builddir/runtests
run: build test
powershell "cp ./builddir/zedcaster.exe ."

@ -31,6 +31,7 @@
"foreground": [156, 172, 197],
"background": [30, 20, 75]
},
{"_type": "LightSource", "strength": 80, "radius": 2.8},
{"_type": "Combat", "hp": 40, "max_hp": 40, "damage": 10, "dead": false},
{"_type": "Motion", "dx": 0, "dy": 0, "random": true},
{"_type": "EnemyConfig", "hearing_distance": 5},

@ -92,10 +92,12 @@ sources = [
executable('runtests', sources + [
'tests/ansi_parser.cpp',
'tests/base.cpp',
'tests/components.cpp',
'tests/config.cpp',
'tests/dbc.cpp',
'tests/dinkyecs.cpp',
'tests/guecs.cpp',
'tests/fsm.cpp',
'tests/guecs.cpp',
'tests/inventory.cpp',
'tests/lel.cpp',
'tests/levelmanager.cpp',
@ -104,9 +106,8 @@ executable('runtests', sources + [
'tests/matrix.cpp',
'tests/pathing.cpp',
'tests/spatialmap.cpp',
'tests/tilemap.cpp',
'tests/components.cpp',
'tests/textures.cpp',
'tests/tilemap.cpp',
], override_options: exe_defaults,
dependencies: dependencies + [catch2])

@ -0,0 +1,18 @@
#include <catch2/catch_test_macros.hpp>
#include "config.hpp"
#include <iostream>
TEST_CASE("confirm basic config loader ops", "[config]") {
Config config("assets/devices.json");
auto data_list = config.json();
for(auto& [key, data] : data_list.items()) {
auto wide1 = config.wstring(key, "name");
auto& comps = data["components"];
for(auto& comp_data : comps) {
REQUIRE(comp_data.contains("_type"));
}
}
}
Loading…
Cancel
Save