build(libconfig): serif now uses libconfig
This commit is contained in:
@@ -25,12 +25,12 @@ TEST_F(compositionTest, isotopeMasses) {
|
||||
}
|
||||
|
||||
TEST_F(compositionTest, constructor) {
|
||||
serif::config::Config::getInstance().loadConfig(EXAMPLE_FILENAME);
|
||||
fourdst::config::Config::getInstance().loadConfig(EXAMPLE_FILENAME);
|
||||
EXPECT_NO_THROW(serif::composition::Composition comp);
|
||||
}
|
||||
|
||||
TEST_F(compositionTest, registerSymbol) {
|
||||
serif::config::Config::getInstance().loadConfig(EXAMPLE_FILENAME);
|
||||
fourdst::config::Config::getInstance().loadConfig(EXAMPLE_FILENAME);
|
||||
serif::composition::Composition comp;
|
||||
EXPECT_NO_THROW(comp.registerSymbol("H-1"));
|
||||
EXPECT_NO_THROW(comp.registerSymbol("He-4"));
|
||||
@@ -45,7 +45,7 @@ TEST_F(compositionTest, registerSymbol) {
|
||||
}
|
||||
|
||||
TEST_F(compositionTest, setGetComposition) {
|
||||
serif::config::Config::getInstance().loadConfig(EXAMPLE_FILENAME);
|
||||
fourdst::config::Config::getInstance().loadConfig(EXAMPLE_FILENAME);
|
||||
serif::composition::Composition comp;
|
||||
comp.registerSymbol("H-1");
|
||||
comp.registerSymbol("He-4");
|
||||
@@ -71,7 +71,7 @@ TEST_F(compositionTest, setGetComposition) {
|
||||
}
|
||||
|
||||
TEST_F(compositionTest, setGetNumberFraction) {
|
||||
serif::config::Config::getInstance().loadConfig(EXAMPLE_FILENAME);
|
||||
fourdst::config::Config::getInstance().loadConfig(EXAMPLE_FILENAME);
|
||||
serif::composition::Composition comp;
|
||||
comp.registerSymbol("H-1", false);
|
||||
comp.registerSymbol("He-4", false);
|
||||
@@ -88,7 +88,7 @@ TEST_F(compositionTest, setGetNumberFraction) {
|
||||
}
|
||||
|
||||
TEST_F(compositionTest, subset) {
|
||||
serif::config::Config::getInstance().loadConfig(EXAMPLE_FILENAME);
|
||||
fourdst::config::Config::getInstance().loadConfig(EXAMPLE_FILENAME);
|
||||
serif::composition::Composition comp;
|
||||
comp.registerSymbol("H-1");
|
||||
comp.registerSymbol("He-4");
|
||||
@@ -103,7 +103,7 @@ TEST_F(compositionTest, subset) {
|
||||
}
|
||||
|
||||
TEST_F(compositionTest, finalizeWithNormalization) {
|
||||
serif::config::Config::getInstance().loadConfig(EXAMPLE_FILENAME);
|
||||
fourdst::config::Config::getInstance().loadConfig(EXAMPLE_FILENAME);
|
||||
serif::composition::Composition comp;
|
||||
comp.registerSymbol("H-1");
|
||||
comp.registerSymbol("He-4");
|
||||
@@ -115,7 +115,7 @@ TEST_F(compositionTest, finalizeWithNormalization) {
|
||||
}
|
||||
|
||||
TEST_F(compositionTest, finalizeWithoutNormalization) {
|
||||
serif::config::Config::getInstance().loadConfig(EXAMPLE_FILENAME);
|
||||
fourdst::config::Config::getInstance().loadConfig(EXAMPLE_FILENAME);
|
||||
serif::composition::Composition comp;
|
||||
comp.registerSymbol("H-1");
|
||||
comp.registerSymbol("He-4");
|
||||
@@ -127,7 +127,7 @@ TEST_F(compositionTest, finalizeWithoutNormalization) {
|
||||
}
|
||||
|
||||
TEST_F(compositionTest, getComposition) {
|
||||
serif::config::Config::getInstance().loadConfig(EXAMPLE_FILENAME);
|
||||
fourdst::config::Config::getInstance().loadConfig(EXAMPLE_FILENAME);
|
||||
serif::composition::Composition comp;
|
||||
comp.registerSymbol("H-1");
|
||||
comp.registerSymbol("He-4");
|
||||
@@ -142,7 +142,7 @@ TEST_F(compositionTest, getComposition) {
|
||||
}
|
||||
|
||||
TEST_F(compositionTest, setCompositionMode) {
|
||||
serif::config::Config::getInstance().loadConfig(EXAMPLE_FILENAME);
|
||||
fourdst::config::Config::getInstance().loadConfig(EXAMPLE_FILENAME);
|
||||
serif::composition::Composition comp;
|
||||
comp.registerSymbol("H-1");
|
||||
comp.registerSymbol("He-4");
|
||||
@@ -164,7 +164,7 @@ TEST_F(compositionTest, setCompositionMode) {
|
||||
}
|
||||
|
||||
TEST_F(compositionTest, hasSymbol) {
|
||||
serif::config::Config::getInstance().loadConfig(EXAMPLE_FILENAME);
|
||||
fourdst::config::Config::getInstance().loadConfig(EXAMPLE_FILENAME);
|
||||
serif::composition::Composition comp;
|
||||
comp.registerSymbol("H-1");
|
||||
comp.registerSymbol("He-4");
|
||||
@@ -179,7 +179,7 @@ TEST_F(compositionTest, hasSymbol) {
|
||||
}
|
||||
|
||||
TEST_F(compositionTest, mix) {
|
||||
serif::config::Config::getInstance().loadConfig(EXAMPLE_FILENAME);
|
||||
fourdst::config::Config::getInstance().loadConfig(EXAMPLE_FILENAME);
|
||||
serif::composition::Composition comp1;
|
||||
comp1.registerSymbol("H-1");
|
||||
comp1.registerSymbol("He-4");
|
||||
|
||||
@@ -9,7 +9,7 @@ int main(int argv, char* argc[]) {
|
||||
} else {
|
||||
pathToConfigFile = "config.json";
|
||||
}
|
||||
serif::config::Config::getInstance().loadConfig(pathToConfigFile);
|
||||
fourdst::config::Config::getInstance().loadConfig(pathToConfigFile);
|
||||
serif::composition::Composition comp;
|
||||
std::vector<std::string> symbols = {"H-1", "He-4"};
|
||||
comp.registerSymbol(symbols);
|
||||
|
||||
@@ -1,111 +0,0 @@
|
||||
#include <gtest/gtest.h>
|
||||
#include "config.h"
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <set>
|
||||
#include <sstream>
|
||||
#include <algorithm>
|
||||
|
||||
std::string EXAMPLE_FILENAME = std::string(getenv("MESON_SOURCE_ROOT")) + "/tests/config/example.yaml";
|
||||
/**
|
||||
* @file configTest.cpp
|
||||
* @brief Unit tests for the Config class.
|
||||
*/
|
||||
|
||||
class configTestPrivateAccessor {
|
||||
public:
|
||||
static bool callIsKeyInCache(serif::config::Config& config, const std::string& key) {
|
||||
return config.isKeyInCache(key);
|
||||
}
|
||||
|
||||
static int callCacheSize(serif::config::Config& config) {
|
||||
return config.configMap.size();
|
||||
}
|
||||
|
||||
static void callAddToCache(serif::config::Config& config, const std::string& key, const YAML::Node& node) {
|
||||
config.addToCache(key, node);
|
||||
}
|
||||
|
||||
static void callRegisterKeyNotFound(serif::config::Config& config, const std::string& key) {
|
||||
config.registerUnknownKey(key);
|
||||
}
|
||||
|
||||
static bool CheckIfKeyUnknown(serif::config::Config& config, const std::string& key) {
|
||||
if (std::find(config.unknownKeys.begin(), config.unknownKeys.end(), key) == config.unknownKeys.end()) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Test suite for the Config class.
|
||||
*/
|
||||
class configTest : public ::testing::Test {};
|
||||
|
||||
/**
|
||||
* @brief Test the constructor of the Config class.
|
||||
*/
|
||||
TEST_F(configTest, constructor) {
|
||||
EXPECT_NO_THROW(serif::config::Config::getInstance());
|
||||
}
|
||||
|
||||
TEST_F(configTest, loadConfig) {
|
||||
serif::config::Config& config = serif::config::Config::getInstance();
|
||||
EXPECT_TRUE(config.loadConfig(EXAMPLE_FILENAME));
|
||||
}
|
||||
|
||||
TEST_F(configTest, singletonTest) {
|
||||
serif::config::Config& config1 = serif::config::Config::getInstance();
|
||||
serif::config::Config& config2 = serif::config::Config::getInstance();
|
||||
EXPECT_EQ(&config1, &config2);
|
||||
}
|
||||
|
||||
TEST_F(configTest, getTest) {
|
||||
serif::config::Config& config = serif::config::Config::getInstance();
|
||||
config.loadConfig(EXAMPLE_FILENAME);
|
||||
int maxIter = config.get<int>("opac:lowTemp:numeric:maxIter", 10);
|
||||
EXPECT_EQ(maxIter, 100);
|
||||
EXPECT_NE(maxIter, 10);
|
||||
|
||||
std::string logLevel = config.get<std::string>("logLevel", "DEBUG");
|
||||
EXPECT_EQ(logLevel, "INFO");
|
||||
EXPECT_NE(logLevel, "DEBUG");
|
||||
|
||||
float polytropicIndex = config.get<float>("poly:physics:index", 2);
|
||||
EXPECT_EQ(polytropicIndex, 1.5);
|
||||
EXPECT_NE(polytropicIndex, 2);
|
||||
|
||||
float polytropicIndex2 = config.get<float>("poly:physics:index2", 2.0);
|
||||
EXPECT_EQ(polytropicIndex2, 2.0);
|
||||
}
|
||||
|
||||
TEST_F(configTest, secondSingletonTest) {
|
||||
serif::config::Config& config = serif::config::Config::getInstance();
|
||||
EXPECT_EQ(config.get<int>("opac:lowTemp:numeric:maxIter", 10), 100);
|
||||
}
|
||||
|
||||
TEST_F(configTest, isKeyInCacheTest) {
|
||||
serif::config::Config& config = serif::config::Config::getInstance();
|
||||
config.loadConfig(EXAMPLE_FILENAME);
|
||||
EXPECT_TRUE(configTestPrivateAccessor::callIsKeyInCache(config, "opac:lowTemp:numeric:maxIter"));
|
||||
EXPECT_FALSE(configTestPrivateAccessor::callIsKeyInCache(config, "opac:lowTemp:numeric:maxIter2"));
|
||||
}
|
||||
|
||||
TEST_F(configTest, cacheSize) {
|
||||
serif::config::Config& config = serif::config::Config::getInstance();
|
||||
config.loadConfig(EXAMPLE_FILENAME);
|
||||
EXPECT_EQ(configTestPrivateAccessor::callCacheSize(config), 3);
|
||||
EXPECT_NE(configTestPrivateAccessor::callCacheSize(config), 4);
|
||||
config.get<std::string>("outputDir", "DEBUG");
|
||||
EXPECT_EQ(configTestPrivateAccessor::callCacheSize(config), 4);
|
||||
}
|
||||
|
||||
TEST_F(configTest, unknownKeyTest) {
|
||||
serif::config::Config& config = serif::config::Config::getInstance();
|
||||
config.loadConfig(EXAMPLE_FILENAME);
|
||||
config.get<int>("opac:lowTemp:numeric:random", 10);
|
||||
EXPECT_FALSE(configTestPrivateAccessor::CheckIfKeyUnknown(config, "opac:lowTemp:numeric:maxIter"));
|
||||
EXPECT_TRUE(configTestPrivateAccessor::CheckIfKeyUnknown(config, "opac:lowTemp:numeric:random"));
|
||||
}
|
||||
@@ -1,32 +0,0 @@
|
||||
# High level options
|
||||
logLevel: "INFO"
|
||||
outputDir: output
|
||||
|
||||
# Module options
|
||||
poly:
|
||||
numeric:
|
||||
newtonTol: 1e-6
|
||||
newtonMaxIter: 100
|
||||
gmresTol: 1e-6
|
||||
gmresMaxIter: 100
|
||||
physics:
|
||||
index: 1.5
|
||||
|
||||
# Module options
|
||||
opac:
|
||||
highTemp:
|
||||
physics:
|
||||
table: "/path/to/highTempTable.dat"
|
||||
numeric:
|
||||
tol: 1e-6
|
||||
maxIter: 100
|
||||
lowTemp:
|
||||
physics:
|
||||
table: "/path/to/lowTempTable.dat"
|
||||
numeric:
|
||||
tol: 1e-6
|
||||
maxIter: 100
|
||||
|
||||
mesh:
|
||||
structure:
|
||||
refine: 2
|
||||
@@ -1,24 +0,0 @@
|
||||
# Test files for const
|
||||
test_sources = [
|
||||
'configTest.cpp',
|
||||
]
|
||||
|
||||
foreach test_file : test_sources
|
||||
exe_name = test_file.split('.')[0]
|
||||
message('Building test: ' + exe_name)
|
||||
|
||||
# Create an executable target for each test
|
||||
test_exe = executable(
|
||||
exe_name,
|
||||
test_file,
|
||||
dependencies: [gtest_dep, config_dep, gtest_main],
|
||||
include_directories: include_directories('../../src/config/public'),
|
||||
install_rpath: '@loader_path/../../src' # Ensure runtime library path resolves correctly
|
||||
)
|
||||
|
||||
# Add the executable as a test
|
||||
test(
|
||||
exe_name,
|
||||
test_exe,
|
||||
env: ['MESON_SOURCE_ROOT=' + meson.project_source_root(), 'MESON_BUILD_ROOT=' + meson.project_build_root()])
|
||||
endforeach
|
||||
@@ -26,7 +26,7 @@ std::string TEST_CONFIG = std::string(getenv("MESON_SOURCE_ROOT")) + "/tests/tes
|
||||
*/
|
||||
|
||||
TEST_F(eosTest, read_helm_table) {
|
||||
serif::config::Config::getInstance().loadConfig(TEST_CONFIG);
|
||||
fourdst::config::Config::getInstance().loadConfig(TEST_CONFIG);
|
||||
const serif::resource::ResourceManager& rm = serif::resource::ResourceManager::getInstance();
|
||||
auto& eos = std::get<std::unique_ptr<serif::eos::EOSio>>(rm.getResource("eos:helm"));
|
||||
const auto& table = eos->getTable();
|
||||
|
||||
@@ -6,7 +6,6 @@ gtest_nomain_dep = dependency('gtest', main: false, required : true)
|
||||
# Subdirectories for unit and integration tests
|
||||
subdir('meshIO')
|
||||
subdir('probe')
|
||||
subdir('config')
|
||||
subdir('eos')
|
||||
subdir('resource')
|
||||
subdir('network')
|
||||
|
||||
@@ -15,7 +15,7 @@ class approx8Test : public ::testing::Test {};
|
||||
* @brief Test the constructor of the Config class.
|
||||
*/
|
||||
TEST_F(approx8Test, constructor) {
|
||||
serif::config::Config& config = serif::config::Config::getInstance();
|
||||
fourdst::config::Config& config = fourdst::config::Config::getInstance();
|
||||
config.loadConfig(TEST_CONFIG);
|
||||
EXPECT_NO_THROW(serif::network::approx8::Approx8Network());
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@ class polyTest : public ::testing::Test {};
|
||||
TEST_F(polyTest, Solve) {
|
||||
using namespace serif::polytrope;
|
||||
|
||||
serif::config::Config& config = serif::config::Config::getInstance();
|
||||
fourdst::config::Config& config = fourdst::config::Config::getInstance();
|
||||
config.loadConfig(CONFIG_FILENAME);
|
||||
fourdst::logging::LogManager& logManager = fourdst::logging::LogManager::getInstance();
|
||||
quill::Logger* logger = logManager.getLogger("log");
|
||||
|
||||
@@ -28,12 +28,12 @@ class resourceManagerTest : public ::testing::Test {};
|
||||
* @brief Test the constructor of the resourceManager class.
|
||||
*/
|
||||
TEST_F(resourceManagerTest, constructor) {
|
||||
serif::config::Config::getInstance().loadConfig(TEST_CONFIG);
|
||||
fourdst::config::Config::getInstance().loadConfig(TEST_CONFIG);
|
||||
EXPECT_NO_THROW(serif::resource::ResourceManager::getInstance());
|
||||
}
|
||||
|
||||
TEST_F(resourceManagerTest, getAvaliableResources) {
|
||||
serif::config::Config::getInstance().loadConfig(TEST_CONFIG);
|
||||
fourdst::config::Config::getInstance().loadConfig(TEST_CONFIG);
|
||||
serif::resource::ResourceManager& rm = serif::resource::ResourceManager::getInstance();
|
||||
std::vector<std::string> resources = rm.getAvailableResources();
|
||||
std::set<std::string> expected = {"eos:helm", "mesh:polySphere"};
|
||||
@@ -42,7 +42,7 @@ TEST_F(resourceManagerTest, getAvaliableResources) {
|
||||
}
|
||||
|
||||
TEST_F(resourceManagerTest, getResource) {
|
||||
serif::config::Config::getInstance().loadConfig(TEST_CONFIG);
|
||||
fourdst::config::Config::getInstance().loadConfig(TEST_CONFIG);
|
||||
serif::resource::ResourceManager& rm = serif::resource::ResourceManager::getInstance();
|
||||
std::string name = "eos:helm";
|
||||
const serif::resource::types::Resource &r = rm.getResource(name);
|
||||
|
||||
Reference in New Issue
Block a user