You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
44 lines
1.0 KiB
44 lines
1.0 KiB
3 weeks ago
|
#include <catch2/catch_test_macros.hpp>
|
||
|
#include <fmt/core.h>
|
||
|
#include <string>
|
||
|
#include "config.hpp"
|
||
|
#include <any>
|
||
|
#include "dinkyecs.hpp"
|
||
|
|
||
|
using namespace fmt;
|
||
|
using std::string;
|
||
|
|
||
|
TEST_CASE("basic configuration system", "[config]") {
|
||
|
Config config("./tests/config.json");
|
||
|
|
||
|
auto not_found = config["types"]["NOTFOUND"];
|
||
|
REQUIRE(not_found == nullptr);
|
||
|
|
||
|
auto test_string = config["types"]["STRING"];
|
||
|
REQUIRE(test_string == L"\u2849█Ω♣");
|
||
|
|
||
|
std::wstring test_wstring = config.wstring("types", "STRING");
|
||
|
REQUIRE(test_wstring == L"\u2849█Ω♣");
|
||
|
|
||
|
wchar_t chr0 = test_wstring[0];
|
||
|
REQUIRE(chr0 == L'\u2849');
|
||
|
|
||
|
auto test_num = config["types"]["NUMBER"];
|
||
|
REQUIRE(test_num == 1234);
|
||
|
|
||
|
auto test_float = config["types"]["FLOAT"];
|
||
|
REQUIRE(test_num >= 0.1233f);
|
||
|
|
||
|
auto test_obj = config["types"]["OBJECT"];
|
||
|
REQUIRE(test_obj["name"] == "Zed");
|
||
|
}
|
||
|
|
||
|
void test_func(Config &ref) {
|
||
|
REQUIRE(ref["types"]["OBJECT"]["name"] == "Zed");
|
||
|
}
|
||
|
|
||
|
TEST_CASE("store config in any", "[config]") {
|
||
|
Config config("./tests/config.json");
|
||
|
test_func(config);
|
||
|
}
|