Added general config

This commit is contained in:
2025-12-31 14:01:18 +01:00
parent 7f98a33d7e
commit c7d9cf8567
5 changed files with 43 additions and 1 deletions

View File

@@ -19,7 +19,12 @@ Config get_config(const std::string &CONFIG_FILE) {
toml_table["contact"]["signal"].value_or(""),
};
Config config = {contact};
General general = {
toml_table["general"]["lang"].value_or(""),
toml_table["general"]["title"].value_or(""),
};
Config config = {contact, general};
return config;
}

View File

@@ -7,8 +7,14 @@ struct Contact {
std::string signal;
};
struct General {
std::string lang;
std::string title;
};
struct Config {
Contact contact;
General general;
};
Config get_config(const std::string &CONFIG_FILE);

View File

@@ -1,5 +1,6 @@
#include "config.hpp"
#include <catch2/catch_all.hpp>
#include <catch2/catch_test_macros.hpp>
#include <string>
TEST_CASE("Checking config file read", "[config]") {
@@ -10,4 +11,6 @@ TEST_CASE("Checking config file read", "[config]") {
REQUIRE(config.contact.author == "author");
REQUIRE(config.contact.email == "email@example.com");
REQUIRE(config.contact.signal == "signal url");
REQUIRE(config.general.lang == "en");
REQUIRE(config.general.title == "Blog");
}