learn-opengl/19-blending-facecull/tests/config_tests.cpp
2026-08-30 13:51:01 -04:00

46 lines
1 KiB
C++

#include <fuc2/testing.hpp>
#include "components.hpp"
#include <fstream>
#include "json.hpp"
#include <nlohmann/json.hpp>
using json = nlohmann::json;
using namespace fuc2;
/*
* This also tests Mesh by using Model to load them.
*/
namespace config_tests {
void test_json_components() {
std::ifstream f{"tests/config.json"};
auto j = json::parse(f);
auto mat = j["material_test"].get<components::Material>();
CHECK(mat.ambient.x == 0.1f, "wrong value");
auto light = j["lighting_test"].get<components::Lighting>();
auto camera = j["camera_test"].get<components::Camera>();
auto model = j["model_test"].get<components::Model>();
auto thing = j["thing_test"].get<components::Thing>();
}
void test_load_json_config() {
std::ifstream f{"config.json"};
auto j = json::parse(f);
auto scene = j["scene"].get<components::Scene>();
}
fuc2::Set TESTS{
.name="config",
.options={ .fail_fast=false },
.tests={
TEST(test_json_components),
TEST(test_load_json_config),
}
};
}