A simple config loader test.
This commit is contained in:
parent
b8bb49df2c
commit
947ccbe180
4 changed files with 24 additions and 4 deletions
2
Makefile
2
Makefile
|
@ -22,7 +22,7 @@ tracy_build:
|
||||||
meson compile -j 10 -C builddir
|
meson compile -j 10 -C builddir
|
||||||
|
|
||||||
test: build
|
test: build
|
||||||
./builddir/runtests "[components]"
|
./builddir/runtests
|
||||||
|
|
||||||
run: build test
|
run: build test
|
||||||
powershell "cp ./builddir/zedcaster.exe ."
|
powershell "cp ./builddir/zedcaster.exe ."
|
||||||
|
|
|
@ -31,6 +31,7 @@
|
||||||
"foreground": [156, 172, 197],
|
"foreground": [156, 172, 197],
|
||||||
"background": [30, 20, 75]
|
"background": [30, 20, 75]
|
||||||
},
|
},
|
||||||
|
{"_type": "LightSource", "strength": 80, "radius": 2.8},
|
||||||
{"_type": "Combat", "hp": 40, "max_hp": 40, "damage": 10, "dead": false},
|
{"_type": "Combat", "hp": 40, "max_hp": 40, "damage": 10, "dead": false},
|
||||||
{"_type": "Motion", "dx": 0, "dy": 0, "random": true},
|
{"_type": "Motion", "dx": 0, "dy": 0, "random": true},
|
||||||
{"_type": "EnemyConfig", "hearing_distance": 5},
|
{"_type": "EnemyConfig", "hearing_distance": 5},
|
||||||
|
|
|
@ -92,10 +92,12 @@ sources = [
|
||||||
executable('runtests', sources + [
|
executable('runtests', sources + [
|
||||||
'tests/ansi_parser.cpp',
|
'tests/ansi_parser.cpp',
|
||||||
'tests/base.cpp',
|
'tests/base.cpp',
|
||||||
|
'tests/components.cpp',
|
||||||
|
'tests/config.cpp',
|
||||||
'tests/dbc.cpp',
|
'tests/dbc.cpp',
|
||||||
'tests/dinkyecs.cpp',
|
'tests/dinkyecs.cpp',
|
||||||
'tests/guecs.cpp',
|
|
||||||
'tests/fsm.cpp',
|
'tests/fsm.cpp',
|
||||||
|
'tests/guecs.cpp',
|
||||||
'tests/inventory.cpp',
|
'tests/inventory.cpp',
|
||||||
'tests/lel.cpp',
|
'tests/lel.cpp',
|
||||||
'tests/levelmanager.cpp',
|
'tests/levelmanager.cpp',
|
||||||
|
@ -104,9 +106,8 @@ executable('runtests', sources + [
|
||||||
'tests/matrix.cpp',
|
'tests/matrix.cpp',
|
||||||
'tests/pathing.cpp',
|
'tests/pathing.cpp',
|
||||||
'tests/spatialmap.cpp',
|
'tests/spatialmap.cpp',
|
||||||
'tests/tilemap.cpp',
|
|
||||||
'tests/components.cpp',
|
|
||||||
'tests/textures.cpp',
|
'tests/textures.cpp',
|
||||||
|
'tests/tilemap.cpp',
|
||||||
], override_options: exe_defaults,
|
], override_options: exe_defaults,
|
||||||
dependencies: dependencies + [catch2])
|
dependencies: dependencies + [catch2])
|
||||||
|
|
||||||
|
|
18
tests/config.cpp
Normal file
18
tests/config.cpp
Normal file
|
@ -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…
Add table
Add a link
Reference in a new issue