feat(pythonInterface/eos): fast forward
This commit is contained in:
@@ -25,13 +25,13 @@ TEST_F(compositionTest, isotopeMasses) {
|
||||
}
|
||||
|
||||
TEST_F(compositionTest, constructor) {
|
||||
Config::getInstance().loadConfig(EXAMPLE_FILENAME);
|
||||
EXPECT_NO_THROW(composition::Composition comp);
|
||||
serif::config::Config::getInstance().loadConfig(EXAMPLE_FILENAME);
|
||||
EXPECT_NO_THROW(serif::composition::Composition comp);
|
||||
}
|
||||
|
||||
TEST_F(compositionTest, registerSymbol) {
|
||||
Config::getInstance().loadConfig(EXAMPLE_FILENAME);
|
||||
composition::Composition comp;
|
||||
serif::config::Config::getInstance().loadConfig(EXAMPLE_FILENAME);
|
||||
serif::composition::Composition comp;
|
||||
EXPECT_NO_THROW(comp.registerSymbol("H-1"));
|
||||
EXPECT_NO_THROW(comp.registerSymbol("He-4"));
|
||||
EXPECT_THROW(comp.registerSymbol("H-19"), std::runtime_error);
|
||||
@@ -45,8 +45,8 @@ TEST_F(compositionTest, registerSymbol) {
|
||||
}
|
||||
|
||||
TEST_F(compositionTest, setGetComposition) {
|
||||
Config::getInstance().loadConfig(EXAMPLE_FILENAME);
|
||||
composition::Composition comp;
|
||||
serif::config::Config::getInstance().loadConfig(EXAMPLE_FILENAME);
|
||||
serif::composition::Composition comp;
|
||||
comp.registerSymbol("H-1");
|
||||
comp.registerSymbol("He-4");
|
||||
|
||||
@@ -71,8 +71,8 @@ TEST_F(compositionTest, setGetComposition) {
|
||||
}
|
||||
|
||||
TEST_F(compositionTest, setGetNumberFraction) {
|
||||
Config::getInstance().loadConfig(EXAMPLE_FILENAME);
|
||||
composition::Composition comp;
|
||||
serif::config::Config::getInstance().loadConfig(EXAMPLE_FILENAME);
|
||||
serif::composition::Composition comp;
|
||||
comp.registerSymbol("H-1", false);
|
||||
comp.registerSymbol("He-4", false);
|
||||
|
||||
@@ -88,8 +88,8 @@ TEST_F(compositionTest, setGetNumberFraction) {
|
||||
}
|
||||
|
||||
TEST_F(compositionTest, subset) {
|
||||
Config::getInstance().loadConfig(EXAMPLE_FILENAME);
|
||||
composition::Composition comp;
|
||||
serif::config::Config::getInstance().loadConfig(EXAMPLE_FILENAME);
|
||||
serif::composition::Composition comp;
|
||||
comp.registerSymbol("H-1");
|
||||
comp.registerSymbol("He-4");
|
||||
comp.setMassFraction("H-1", 0.6);
|
||||
@@ -97,14 +97,14 @@ TEST_F(compositionTest, subset) {
|
||||
EXPECT_NO_THROW(comp.finalize());
|
||||
|
||||
std::vector<std::string> symbols = {"H-1"};
|
||||
composition::Composition subsetComp = comp.subset(symbols, "norm");
|
||||
serif::composition::Composition subsetComp = comp.subset(symbols, "norm");
|
||||
EXPECT_TRUE(subsetComp.finalize());
|
||||
EXPECT_DOUBLE_EQ(subsetComp.getMassFraction("H-1"), 1.0);
|
||||
}
|
||||
|
||||
TEST_F(compositionTest, finalizeWithNormalization) {
|
||||
Config::getInstance().loadConfig(EXAMPLE_FILENAME);
|
||||
composition::Composition comp;
|
||||
serif::config::Config::getInstance().loadConfig(EXAMPLE_FILENAME);
|
||||
serif::composition::Composition comp;
|
||||
comp.registerSymbol("H-1");
|
||||
comp.registerSymbol("He-4");
|
||||
comp.setMassFraction("H-1", 0.3);
|
||||
@@ -115,8 +115,8 @@ TEST_F(compositionTest, finalizeWithNormalization) {
|
||||
}
|
||||
|
||||
TEST_F(compositionTest, finalizeWithoutNormalization) {
|
||||
Config::getInstance().loadConfig(EXAMPLE_FILENAME);
|
||||
composition::Composition comp;
|
||||
serif::config::Config::getInstance().loadConfig(EXAMPLE_FILENAME);
|
||||
serif::composition::Composition comp;
|
||||
comp.registerSymbol("H-1");
|
||||
comp.registerSymbol("He-4");
|
||||
comp.setMassFraction("H-1", 0.5);
|
||||
@@ -127,8 +127,8 @@ TEST_F(compositionTest, finalizeWithoutNormalization) {
|
||||
}
|
||||
|
||||
TEST_F(compositionTest, getComposition) {
|
||||
Config::getInstance().loadConfig(EXAMPLE_FILENAME);
|
||||
composition::Composition comp;
|
||||
serif::config::Config::getInstance().loadConfig(EXAMPLE_FILENAME);
|
||||
serif::composition::Composition comp;
|
||||
comp.registerSymbol("H-1");
|
||||
comp.registerSymbol("He-4");
|
||||
comp.setMassFraction("H-1", 0.6);
|
||||
@@ -142,8 +142,8 @@ TEST_F(compositionTest, getComposition) {
|
||||
}
|
||||
|
||||
TEST_F(compositionTest, setCompositionMode) {
|
||||
Config::getInstance().loadConfig(EXAMPLE_FILENAME);
|
||||
composition::Composition comp;
|
||||
serif::config::Config::getInstance().loadConfig(EXAMPLE_FILENAME);
|
||||
serif::composition::Composition comp;
|
||||
comp.registerSymbol("H-1");
|
||||
comp.registerSymbol("He-4");
|
||||
comp.setMassFraction("H-1", 0.6);
|
||||
@@ -164,8 +164,8 @@ TEST_F(compositionTest, setCompositionMode) {
|
||||
}
|
||||
|
||||
TEST_F(compositionTest, hasSymbol) {
|
||||
Config::getInstance().loadConfig(EXAMPLE_FILENAME);
|
||||
composition::Composition comp;
|
||||
serif::config::Config::getInstance().loadConfig(EXAMPLE_FILENAME);
|
||||
serif::composition::Composition comp;
|
||||
comp.registerSymbol("H-1");
|
||||
comp.registerSymbol("He-4");
|
||||
comp.setMassFraction("H-1", 0.6);
|
||||
@@ -179,27 +179,27 @@ TEST_F(compositionTest, hasSymbol) {
|
||||
}
|
||||
|
||||
TEST_F(compositionTest, mix) {
|
||||
Config::getInstance().loadConfig(EXAMPLE_FILENAME);
|
||||
composition::Composition comp1;
|
||||
serif::config::Config::getInstance().loadConfig(EXAMPLE_FILENAME);
|
||||
serif::composition::Composition comp1;
|
||||
comp1.registerSymbol("H-1");
|
||||
comp1.registerSymbol("He-4");
|
||||
comp1.setMassFraction("H-1", 0.6);
|
||||
comp1.setMassFraction("He-4", 0.4);
|
||||
EXPECT_NO_THROW(comp1.finalize());
|
||||
|
||||
composition::Composition comp2;
|
||||
serif::composition::Composition comp2;
|
||||
comp2.registerSymbol("H-1");
|
||||
comp2.registerSymbol("He-4");
|
||||
comp2.setMassFraction("H-1", 0.4);
|
||||
comp2.setMassFraction("He-4", 0.6);
|
||||
EXPECT_NO_THROW(comp2.finalize());
|
||||
|
||||
composition::Composition mixedComp = comp1 + comp2;
|
||||
serif::composition::Composition mixedComp = comp1 + comp2;
|
||||
EXPECT_TRUE(mixedComp.finalize());
|
||||
EXPECT_DOUBLE_EQ(mixedComp.getMassFraction("H-1"), 0.5);
|
||||
EXPECT_DOUBLE_EQ(mixedComp.getMassFraction("He-4"), 0.5);
|
||||
|
||||
composition::Composition mixedComp2 = comp1.mix(comp2, 0.25);
|
||||
serif::composition::Composition mixedComp2 = comp1.mix(comp2, 0.25);
|
||||
EXPECT_TRUE(mixedComp2.finalize());
|
||||
EXPECT_DOUBLE_EQ(mixedComp2.getMassFraction("H-1"), 0.45);
|
||||
EXPECT_DOUBLE_EQ(mixedComp2.getMassFraction("He-4"), 0.55);
|
||||
|
||||
@@ -9,7 +9,8 @@ int main(int argv, char* argc[]) {
|
||||
} else {
|
||||
pathToConfigFile = "config.json";
|
||||
}
|
||||
composition::Composition comp;
|
||||
serif::config::Config::getInstance().loadConfig(pathToConfigFile);
|
||||
serif::composition::Composition comp;
|
||||
std::vector<std::string> symbols = {"H-1", "He-4"};
|
||||
comp.registerSymbol(symbols);
|
||||
comp.setMassFraction("H-1", 0.7);
|
||||
@@ -24,7 +25,7 @@ int main(int argv, char* argc[]) {
|
||||
std::cout << "\tMass Frac Sum: " << comp.getMassFraction("H-1") + comp.getMassFraction("He-4") << std::endl;
|
||||
std::cout << "\tNumber Frac Sum: " << comp.getNumberFraction("H-1") + comp.getNumberFraction("He-4") << std::endl;
|
||||
|
||||
composition::Composition comp2;
|
||||
serif::composition::Composition comp2;
|
||||
comp2.registerSymbol(symbols, false);
|
||||
comp2.setNumberFraction("H-1", comp.getNumberFraction("H-1"));
|
||||
comp2.setNumberFraction("He-4", comp.getNumberFraction("He-4"));
|
||||
@@ -72,7 +73,7 @@ int main(int argv, char* argc[]) {
|
||||
0.0004,
|
||||
0.00006
|
||||
};
|
||||
composition::Composition comp3(symbols3, mass_fractions, true);
|
||||
serif::composition::Composition comp3(symbols3, mass_fractions, true);
|
||||
std::cout << "=== Mass Fraction Mode ===" << std::endl;
|
||||
double massFracSum = 0.0;
|
||||
double numberFracSum = 0.0;
|
||||
|
||||
@@ -15,23 +15,23 @@ std::string EXAMPLE_FILENAME = std::string(getenv("MESON_SOURCE_ROOT")) + "/test
|
||||
|
||||
class configTestPrivateAccessor {
|
||||
public:
|
||||
static bool callIsKeyInCache(Config& config, const std::string& key) {
|
||||
static bool callIsKeyInCache(serif::config::Config& config, const std::string& key) {
|
||||
return config.isKeyInCache(key);
|
||||
}
|
||||
|
||||
static int callCacheSize(Config& config) {
|
||||
static int callCacheSize(serif::config::Config& config) {
|
||||
return config.configMap.size();
|
||||
}
|
||||
|
||||
static void callAddToCache(Config& config, const std::string& key, const YAML::Node& node) {
|
||||
static void callAddToCache(serif::config::Config& config, const std::string& key, const YAML::Node& node) {
|
||||
config.addToCache(key, node);
|
||||
}
|
||||
|
||||
static void callRegisterKeyNotFound(Config& config, const std::string& key) {
|
||||
static void callRegisterKeyNotFound(serif::config::Config& config, const std::string& key) {
|
||||
config.registerUnknownKey(key);
|
||||
}
|
||||
|
||||
static bool CheckIfKeyUnknown(Config& config, const std::string& 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;
|
||||
}
|
||||
@@ -48,22 +48,22 @@ class configTest : public ::testing::Test {};
|
||||
* @brief Test the constructor of the Config class.
|
||||
*/
|
||||
TEST_F(configTest, constructor) {
|
||||
EXPECT_NO_THROW(Config::getInstance());
|
||||
EXPECT_NO_THROW(serif::config::Config::getInstance());
|
||||
}
|
||||
|
||||
TEST_F(configTest, loadConfig) {
|
||||
Config& config = Config::getInstance();
|
||||
serif::config::Config& config = serif::config::Config::getInstance();
|
||||
EXPECT_TRUE(config.loadConfig(EXAMPLE_FILENAME));
|
||||
}
|
||||
|
||||
TEST_F(configTest, singletonTest) {
|
||||
Config& config1 = Config::getInstance();
|
||||
Config& config2 = Config::getInstance();
|
||||
serif::config::Config& config1 = serif::config::Config::getInstance();
|
||||
serif::config::Config& config2 = serif::config::Config::getInstance();
|
||||
EXPECT_EQ(&config1, &config2);
|
||||
}
|
||||
|
||||
TEST_F(configTest, getTest) {
|
||||
Config& config = Config::getInstance();
|
||||
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);
|
||||
@@ -82,19 +82,19 @@ TEST_F(configTest, getTest) {
|
||||
}
|
||||
|
||||
TEST_F(configTest, secondSingletonTest) {
|
||||
Config& config = Config::getInstance();
|
||||
serif::config::Config& config = serif::config::Config::getInstance();
|
||||
EXPECT_EQ(config.get<int>("opac:lowTemp:numeric:maxIter", 10), 100);
|
||||
}
|
||||
|
||||
TEST_F(configTest, isKeyInCacheTest) {
|
||||
Config& config = Config::getInstance();
|
||||
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) {
|
||||
Config& config = Config::getInstance();
|
||||
serif::config::Config& config = serif::config::Config::getInstance();
|
||||
config.loadConfig(EXAMPLE_FILENAME);
|
||||
EXPECT_EQ(configTestPrivateAccessor::callCacheSize(config), 3);
|
||||
EXPECT_NE(configTestPrivateAccessor::callCacheSize(config), 4);
|
||||
@@ -103,9 +103,9 @@ TEST_F(configTest, cacheSize) {
|
||||
}
|
||||
|
||||
TEST_F(configTest, unknownKeyTest) {
|
||||
Config& config = Config::getInstance();
|
||||
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"));
|
||||
}
|
||||
}
|
||||
@@ -17,7 +17,7 @@
|
||||
class constTest : public ::testing::Test {
|
||||
protected:
|
||||
void SetUp() override {
|
||||
Constants::getInstance();
|
||||
serif::constant::Constants::getInstance();
|
||||
}
|
||||
};
|
||||
|
||||
@@ -25,7 +25,7 @@ protected:
|
||||
* @test Verify default constructor initializes correctly.
|
||||
*/
|
||||
TEST_F(constTest, DefaultConstructor) {
|
||||
EXPECT_NO_THROW(Constants::getInstance());
|
||||
EXPECT_NO_THROW(serif::constant::Constants::getInstance());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -33,14 +33,14 @@ TEST_F(constTest, DefaultConstructor) {
|
||||
*/
|
||||
TEST_F(constTest, isLoaded) {
|
||||
|
||||
EXPECT_NO_THROW(Constants::getInstance().isLoaded());
|
||||
EXPECT_NO_THROW(serif::constant::Constants::getInstance().isLoaded());
|
||||
}
|
||||
|
||||
/**
|
||||
* @test Verify get method returns the correct constant.
|
||||
*/
|
||||
TEST_F(constTest, GetMethod) {
|
||||
Constants& obj = Constants::getInstance();
|
||||
serif::constant::Constants& obj = serif::constant::Constants::getInstance();
|
||||
EXPECT_DOUBLE_EQ(obj.get("c").value, 2.99792458e10);
|
||||
EXPECT_EQ(obj.get("c").unit, "cm / s");
|
||||
EXPECT_DOUBLE_EQ(obj.get("c").uncertainty, 0.0);
|
||||
@@ -51,7 +51,7 @@ TEST_F(constTest, GetMethod) {
|
||||
* @test Verify [] opperators returns the correct constant.
|
||||
*/
|
||||
TEST_F(constTest, SubscriptOperator) {
|
||||
Constants& obj = Constants::getInstance();
|
||||
serif::constant::Constants& obj = serif::constant::Constants::getInstance();
|
||||
EXPECT_DOUBLE_EQ(obj["c"].value, 2.99792458e10);
|
||||
EXPECT_EQ(obj["c"].unit, "cm / s");
|
||||
EXPECT_DOUBLE_EQ(obj["c"].uncertainty, 0.0);
|
||||
@@ -62,7 +62,7 @@ TEST_F(constTest, SubscriptOperator) {
|
||||
* @test Verify that the has method returns the correct values
|
||||
*/
|
||||
TEST_F(constTest, HasMethod) {
|
||||
Constants& obj = Constants::getInstance();
|
||||
serif::constant::Constants& obj = serif::constant::Constants::getInstance();
|
||||
|
||||
EXPECT_TRUE(obj.has("c"));
|
||||
EXPECT_FALSE(obj.has("c4"));
|
||||
@@ -70,7 +70,7 @@ TEST_F(constTest, HasMethod) {
|
||||
}
|
||||
|
||||
TEST_F(constTest, KeysMethod) {
|
||||
Constants& obj = Constants::getInstance();
|
||||
serif::constant::Constants& obj = serif::constant::Constants::getInstance();
|
||||
std::set<std::string> checkKeys;
|
||||
checkKeys.insert("c");
|
||||
checkKeys.insert("wienK");
|
||||
@@ -99,7 +99,7 @@ TEST_F(constTest, KeysMethod) {
|
||||
}
|
||||
|
||||
TEST_F(constTest, StreamOperator) {
|
||||
Constants& obj = Constants::getInstance();
|
||||
serif::constant::Constants& obj = serif::constant::Constants::getInstance();
|
||||
std::ostringstream os;
|
||||
|
||||
os << obj.get("c");
|
||||
|
||||
@@ -12,7 +12,7 @@ foreach test_file : test_sources
|
||||
exe_name,
|
||||
test_file,
|
||||
dependencies: [gtest_dep, const_dep, gtest_main],
|
||||
include_directories: include_directories('../../src/const/public'),
|
||||
include_directories: include_directories('../../src/constants/public'),
|
||||
link_with: libconst, # Link the dobj library
|
||||
install_rpath: '@loader_path/../../src' # Ensure runtime library path resolves correctly
|
||||
)
|
||||
|
||||
@@ -1,86 +0,0 @@
|
||||
#include <gtest/gtest.h>
|
||||
#include "DObject.h"
|
||||
#include "Metadata.h"
|
||||
|
||||
/**
|
||||
* @file DObjectTest.cpp
|
||||
* @brief Unit tests for the DObject class.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Test suite for the DObject class.
|
||||
*/
|
||||
class DObjectTest : public ::testing::Test {
|
||||
protected:
|
||||
DObject defaultObject;
|
||||
DObject initializedObject;
|
||||
|
||||
void SetUp() override {
|
||||
// Create a DObject with initial data and metadata
|
||||
DObject initializedObject(std::vector<float>{1.0f, 2.0f, 3.0f, 4.0f});
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @test Verify default constructor initializes correctly.
|
||||
*/
|
||||
TEST_F(DObjectTest, DefaultConstructor) {
|
||||
EXPECT_NO_THROW(DObject());
|
||||
EXPECT_NO_THROW(auto data = defaultObject.getData());
|
||||
EXPECT_FALSE(defaultObject.isDebuggingEnabled());
|
||||
}
|
||||
|
||||
/**
|
||||
* @test Verify constructor initializes with provided data and metadata.
|
||||
*/
|
||||
TEST_F(DObjectTest, ParameterizedConstructor) {
|
||||
DObject obj(std::vector<int>{1, 2, 3});
|
||||
|
||||
EXPECT_NO_THROW(obj.getData());
|
||||
EXPECT_EQ(std::get<std::vector<int>>(obj.getData()), std::vector<int>({1, 2, 3}));
|
||||
}
|
||||
|
||||
/**
|
||||
* @test Verify getter and setter for data.
|
||||
*/
|
||||
TEST_F(DObjectTest, DataSetterGetter) {
|
||||
std::vector<double> newData = {3.14, 2.71, 1.61};
|
||||
EXPECT_NO_THROW(defaultObject.setData(newData));
|
||||
EXPECT_EQ(std::get<std::vector<double>>(defaultObject.getData()), newData);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test Verify enabling and disabling debugging.
|
||||
*/
|
||||
TEST_F(DObjectTest, DebuggingFlag) {
|
||||
EXPECT_FALSE(defaultObject.isDebuggingEnabled());
|
||||
defaultObject.setDebugging(true);
|
||||
EXPECT_TRUE(defaultObject.isDebuggingEnabled());
|
||||
defaultObject.setDebugging(false);
|
||||
EXPECT_FALSE(defaultObject.isDebuggingEnabled());
|
||||
}
|
||||
|
||||
TEST_F(DObjectTest, ErrorCodeSetteGetter) {
|
||||
int prevCode;
|
||||
prevCode = defaultObject.setErrorCode(1);
|
||||
EXPECT_EQ(prevCode, 0);
|
||||
prevCode = defaultObject.setErrorCode(2);
|
||||
EXPECT_EQ(prevCode, 1);
|
||||
int getCode;
|
||||
getCode = defaultObject.getErrorCode();
|
||||
EXPECT_EQ(getCode, 2);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test Basic Integration Test
|
||||
*/
|
||||
TEST_F(DObjectTest, IntegrationTest) {
|
||||
float data = 55.86868;
|
||||
DObject obj;
|
||||
obj.setData(data);
|
||||
float newData;
|
||||
newData = std::get<float>(obj.getData());
|
||||
EXPECT_EQ(data, newData);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,89 +0,0 @@
|
||||
#include <gtest/gtest.h>
|
||||
#include "LockableDObject.h"
|
||||
#include <thread>
|
||||
#include <vector>
|
||||
|
||||
/**
|
||||
* @file LockableDObjectTest.cpp
|
||||
* @brief Unit tests for the LockableDObject class.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Test suite for the LockableDObject class.
|
||||
*/
|
||||
class LockableDObjectTest : public ::testing::Test {
|
||||
protected:
|
||||
LockableDObject lockableObject;
|
||||
|
||||
void SetUp() override {
|
||||
// Initialize the LockableDObject for tests
|
||||
DObject& obj = lockableObject.get();
|
||||
obj.setData(42); // Set initial data
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @test Verify the default construction of LockableDObject.
|
||||
*/
|
||||
TEST_F(LockableDObjectTest, DefaultConstruction) {
|
||||
EXPECT_NO_THROW(LockableDObject obj);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test Verify access to the underlying DObject.
|
||||
*/
|
||||
TEST_F(LockableDObjectTest, AccessDObject) {
|
||||
DObject& obj = lockableObject.get();
|
||||
EXPECT_EQ(std::get<int>(obj.getData()), 42); // Ensure the data is accessible
|
||||
}
|
||||
|
||||
/**
|
||||
* @test Verify locking and unlocking.
|
||||
*/
|
||||
TEST_F(LockableDObjectTest, LockAndUnlock) {
|
||||
EXPECT_NO_THROW(lockableObject.lock());
|
||||
EXPECT_NO_THROW(lockableObject.unlock());
|
||||
}
|
||||
|
||||
/**
|
||||
* @test Verify thread safety with multiple threads.
|
||||
*/
|
||||
TEST_F(LockableDObjectTest, ThreadSafety) {
|
||||
const int numThreads = 10;
|
||||
std::vector<std::thread> threads;
|
||||
std::atomic<int> successCount{0};
|
||||
|
||||
// Each thread tries to update the data
|
||||
for (int i = 0; i < numThreads; ++i) {
|
||||
threads.emplace_back([this, i, &successCount]() {
|
||||
lockableObject.lock();
|
||||
DObject& obj = lockableObject.get();
|
||||
obj.setData(i);
|
||||
if (std::get<int>(obj.getData()) == i) {
|
||||
successCount++;
|
||||
}
|
||||
lockableObject.unlock();
|
||||
});
|
||||
}
|
||||
|
||||
for (auto& t : threads) {
|
||||
t.join();
|
||||
}
|
||||
|
||||
EXPECT_EQ(successCount, numThreads);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test Verify that the DObject remains consistent when accessed via LockableDObject.
|
||||
*/
|
||||
TEST_F(LockableDObjectTest, ConsistentState) {
|
||||
lockableObject.lock();
|
||||
DObject& obj = lockableObject.get();
|
||||
obj.setData(100);
|
||||
EXPECT_EQ(std::get<int>(obj.getData()), 100);
|
||||
lockableObject.unlock();
|
||||
|
||||
lockableObject.lock();
|
||||
EXPECT_EQ(std::get<int>(lockableObject.get().getData()), 100);
|
||||
lockableObject.unlock();
|
||||
}
|
||||
@@ -1,162 +0,0 @@
|
||||
#include <gtest/gtest.h>
|
||||
#include <thread>
|
||||
#include "Metadata.h"
|
||||
|
||||
/**
|
||||
* @file MetadataTest.cpp
|
||||
* @brief Unit tests and integration tests for the Metadata class.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Test suite for the Metadata class.
|
||||
*/
|
||||
class MetadataTest : public ::testing::Test {
|
||||
protected:
|
||||
void SetUp() override {
|
||||
// Common setup for tests (if needed)
|
||||
}
|
||||
|
||||
void TearDown() override {
|
||||
// Clean up after tests (if needed)
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @test Verify default constructor initializes correctly.
|
||||
*/
|
||||
TEST_F(MetadataTest, DefaultConstructor) {
|
||||
Metadata metadata;
|
||||
|
||||
int expectedByteSize = 0;
|
||||
|
||||
EXPECT_EQ(metadata.getByteSize(), expectedByteSize);
|
||||
EXPECT_EQ(metadata.getDataType(), "");
|
||||
EXPECT_TRUE(metadata.getDimensions().empty());
|
||||
EXPECT_FALSE(metadata.isDebugEnabled());
|
||||
}
|
||||
|
||||
/**
|
||||
* @test Verify parameterized constructor initializes correctly.
|
||||
*/
|
||||
TEST_F(MetadataTest, ParameterizedConstructor) {
|
||||
std::vector<std::size_t> dimensions = {3, 4, 5};
|
||||
Metadata metadata(120, "float", dimensions, true);
|
||||
|
||||
int expectedByteSize = 120;
|
||||
EXPECT_EQ(metadata.getByteSize(), expectedByteSize);
|
||||
EXPECT_EQ(metadata.getDataType(), "float");
|
||||
EXPECT_EQ(metadata.getDimensions(), dimensions);
|
||||
EXPECT_TRUE(metadata.isDebugEnabled());
|
||||
}
|
||||
|
||||
/**
|
||||
* @test Verify setters and getters for byte size.
|
||||
*/
|
||||
TEST_F(MetadataTest, ByteSizeSetterGetter) {
|
||||
Metadata metadata;
|
||||
metadata.setByteSize(256);
|
||||
|
||||
EXPECT_EQ(metadata.getByteSize(), 256);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test Verify setters and getters for data type.
|
||||
*/
|
||||
TEST_F(MetadataTest, DataTypeSetterGetter) {
|
||||
Metadata metadata;
|
||||
metadata.setDataType("double");
|
||||
|
||||
EXPECT_EQ(metadata.getDataType(), "double");
|
||||
}
|
||||
|
||||
/**
|
||||
* @test Verify setters and getters for dimensions.
|
||||
*/
|
||||
TEST_F(MetadataTest, DimensionsSetterGetter) {
|
||||
Metadata metadata;
|
||||
std::vector<std::size_t> dimensions = {2, 2, 2};
|
||||
metadata.setDimensions(dimensions);
|
||||
|
||||
EXPECT_EQ(metadata.getDimensions(), dimensions);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test Verify setters and getters for debug flag.
|
||||
*/
|
||||
TEST_F(MetadataTest, DebugFlagSetterGetter) {
|
||||
Metadata metadata;
|
||||
metadata.setDebugEnabled(true);
|
||||
|
||||
EXPECT_TRUE(metadata.isDebugEnabled());
|
||||
|
||||
metadata.setDebugEnabled(false);
|
||||
|
||||
EXPECT_FALSE(metadata.isDebugEnabled());
|
||||
}
|
||||
|
||||
/**
|
||||
* @test Verify metadata output with operator<<.
|
||||
*/
|
||||
TEST_F(MetadataTest, MetadataOutputOperator) {
|
||||
Metadata metadata(64, "int", {8, 8}, true);
|
||||
|
||||
std::ostringstream oss;
|
||||
oss << metadata;
|
||||
|
||||
std::string expectedOutput = "Metadata Information:\n"
|
||||
" Byte Size: 64 bytes\n"
|
||||
" Data Type: int\n"
|
||||
" Dimensions: [8, 8]\n"
|
||||
" Debug Enabled: Yes\n";
|
||||
|
||||
EXPECT_EQ(oss.str(), expectedOutput);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test Integration test: Validate metadata behavior in a multi-step scenario.
|
||||
*/
|
||||
TEST_F(MetadataTest, IntegrationScenario) {
|
||||
Metadata metadata;
|
||||
|
||||
// Step 1: Initialize metadata with some values
|
||||
metadata.setByteSize(128);
|
||||
metadata.setDataType("float");
|
||||
metadata.setDimensions({4, 4, 2});
|
||||
metadata.setDebugEnabled(true);
|
||||
|
||||
EXPECT_EQ(metadata.getByteSize(), 128);
|
||||
EXPECT_EQ(metadata.getDataType(), "float");
|
||||
EXPECT_EQ(metadata.getDimensions(), (std::vector<std::size_t>{4, 4, 2}));
|
||||
EXPECT_TRUE(metadata.isDebugEnabled());
|
||||
|
||||
// Step 2: Simulate a metadata update
|
||||
metadata.setByteSize(256);
|
||||
metadata.setDataType("double");
|
||||
metadata.setDimensions({8, 8});
|
||||
metadata.setDebugEnabled(false);
|
||||
|
||||
EXPECT_EQ(metadata.getByteSize(), 256);
|
||||
EXPECT_EQ(metadata.getDataType(), "double");
|
||||
EXPECT_EQ(metadata.getDimensions(), (std::vector<std::size_t>{8, 8}));
|
||||
EXPECT_FALSE(metadata.isDebugEnabled());
|
||||
}
|
||||
|
||||
/**
|
||||
* @test Integration test: Handling edge cases for metadata.
|
||||
*/
|
||||
TEST_F(MetadataTest, EdgeCaseHandling) {
|
||||
Metadata metadata;
|
||||
|
||||
// Case 1: Empty dimensions
|
||||
metadata.setDimensions({});
|
||||
EXPECT_TRUE(metadata.getDimensions().empty());
|
||||
|
||||
// Case 2: Large byte size
|
||||
metadata.setByteSize(static_cast<std::size_t>(-1));
|
||||
EXPECT_EQ(metadata.getByteSize(), static_cast<std::size_t>(-1));
|
||||
|
||||
// Case 3: Empty data type
|
||||
metadata.setDataType("");
|
||||
EXPECT_EQ(metadata.getDataType(), "");
|
||||
}
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
test_file = 'testDObject.cpp'
|
||||
exe_name = test_file.split('.')[0]
|
||||
executable(
|
||||
exe_name,
|
||||
test_file,
|
||||
include_directories: include_directories('../../src/dobj/public'),
|
||||
link_with: libdobj, # Link the dobj library
|
||||
install_rpath: '@loader_path/../../src' # Ensure runtime library path resolves correctly
|
||||
)
|
||||
@@ -1,31 +0,0 @@
|
||||
#include<iostream>
|
||||
|
||||
#include "DObject.h"
|
||||
|
||||
DObject testFunction(DObject &obj);
|
||||
|
||||
int main(){
|
||||
float data = 55.86868;
|
||||
DObject obj;
|
||||
obj.setData(data);
|
||||
float newData;
|
||||
newData = std::get<float>(obj.getData());
|
||||
std::cout << "Data: " << newData << std::endl;
|
||||
std::cout << "Calling test function" << std::endl;
|
||||
DObject newObj = testFunction(obj);
|
||||
std::cout << newObj << std::endl;
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Test function which takes a DObject as an argument and
|
||||
// returns new DObject with an vector of 10 elements identical to the input DObject
|
||||
// This should use std::varient and auto to do some degree of type inference
|
||||
DObject testFunction(DObject &obj){
|
||||
float data = obj.getDataAs<float>();
|
||||
std::cout << "Data: " << data << std::endl;
|
||||
std::vector<std::vector<float>> newData(3, std::vector<float>(3, data));
|
||||
DObject newObj(newData);
|
||||
std::cout << obj << std::endl;
|
||||
|
||||
return newObj;
|
||||
}
|
||||
@@ -25,22 +25,21 @@ std::string TEST_CONFIG = std::string(getenv("MESON_SOURCE_ROOT")) + "/tests/tes
|
||||
*/
|
||||
|
||||
TEST_F(eosTest, read_helm_table) {
|
||||
Config::getInstance().loadConfig(TEST_CONFIG);
|
||||
ResourceManager& rm = ResourceManager::getInstance();
|
||||
auto& eos = std::get<std::unique_ptr<EOSio>>(rm.getResource("eos:helm"));
|
||||
serif::config::Config::getInstance().loadConfig(TEST_CONFIG);
|
||||
serif::resource::ResourceManager& rm = serif::resource::ResourceManager::getInstance();
|
||||
auto& eos = std::get<std::unique_ptr<serif::eos::EOSio>>(rm.getResource("eos:helm"));
|
||||
auto& table = eos->getTable();
|
||||
auto& helmTable = *std::get<std::unique_ptr<helmholtz::HELMTable>>(table);
|
||||
auto& helmTable = *std::get<std::unique_ptr<serif::eos::helmholtz::HELMTable>>(table);
|
||||
std::stringstream ss;
|
||||
ss << helmTable;
|
||||
EXPECT_EQ(ss.str(), "HELMTable Data:\n imax: 541, jmax: 201\n Temperature Range: [1000, 1e+13]\n Density Range: [1e-12, 1e+15]\n");
|
||||
}
|
||||
|
||||
TEST_F(eosTest, get_helm_EOS) {
|
||||
using namespace helmholtz;
|
||||
|
||||
const int nel=3;
|
||||
double xmass[nel], aion[nel], zion[nel];
|
||||
EOSInput eos1;
|
||||
serif::eos::helmholtz::EOSInput eos1;
|
||||
|
||||
xmass[0] = 0.75; aion[0] = 1.0; zion[0] = 1.0;
|
||||
xmass[1] = 0.23; aion[1] = 4.0; zion[1] = 2.0;
|
||||
@@ -58,11 +57,11 @@ TEST_F(eosTest, get_helm_EOS) {
|
||||
eos1.abar = 1.0/asum;
|
||||
eos1.zbar = eos1.abar*zsum;
|
||||
|
||||
ResourceManager& rm = ResourceManager::getInstance();
|
||||
auto& eos = std::get<std::unique_ptr<EOSio>>(rm.getResource("eos:helm"));
|
||||
serif::resource::ResourceManager& rm = serif::resource::ResourceManager::getInstance();
|
||||
auto& eos = std::get<std::unique_ptr<serif::eos::EOSio>>(rm.getResource("eos:helm"));
|
||||
auto& table = eos->getTable();
|
||||
auto& helmTable = *std::get<std::unique_ptr<helmholtz::HELMTable>>(table);
|
||||
EOS helmEos = get_helm_EOS(eos1, helmTable);
|
||||
auto& helmTable = *std::get<std::unique_ptr<serif::eos::helmholtz::HELMTable>>(table);
|
||||
serif::eos::helmholtz::EOS helmEos = get_helm_EOS(eos1, helmTable);
|
||||
|
||||
const double absErr = 1e-12;
|
||||
|
||||
|
||||
@@ -19,19 +19,26 @@ double ComputeMeshVolume(mfem::Mesh &mesh)
|
||||
class meshIOTest : public ::testing::Test {};
|
||||
|
||||
TEST_F(meshIOTest, DefaultConstructor) {
|
||||
EXPECT_NO_THROW(MeshIO meshIO(EXAMPLE_FILENAME));
|
||||
EXPECT_NO_THROW(serif::mesh::MeshIO meshIO(EXAMPLE_FILENAME));
|
||||
}
|
||||
|
||||
TEST_F(meshIOTest, IsLoaded) {
|
||||
MeshIO meshIO(EXAMPLE_FILENAME);
|
||||
serif::mesh::MeshIO meshIO(EXAMPLE_FILENAME);
|
||||
EXPECT_EQ(meshIO.IsLoaded(), true);
|
||||
}
|
||||
|
||||
TEST_F(meshIOTest, GetMesh) {
|
||||
MeshIO meshIO(EXAMPLE_FILENAME);
|
||||
serif::mesh::MeshIO meshIO(EXAMPLE_FILENAME);
|
||||
mfem::Mesh& mesh = meshIO.GetMesh();
|
||||
EXPECT_EQ(mesh.GetNE(), 670);
|
||||
EXPECT_EQ(mesh.GetNV(), 201);
|
||||
EXPECT_EQ(mesh.GetNE(), 18351);
|
||||
EXPECT_EQ(mesh.GetNV(), 3768);
|
||||
double volume = ComputeMeshVolume(mesh);
|
||||
EXPECT_DOUBLE_EQ(volume, 3.9357596288315868);
|
||||
EXPECT_DOUBLE_EQ(volume, 4.160516453529322);
|
||||
}
|
||||
|
||||
TEST_F(meshIOTest, LinearRescale) {
|
||||
serif::mesh::MeshIO meshIO(EXAMPLE_FILENAME, 5);
|
||||
mfem::Mesh& mesh = meshIO.GetMesh();
|
||||
double volume = ComputeMeshVolume(mesh);
|
||||
EXPECT_DOUBLE_EQ(volume, 520.06455669116463);
|
||||
}
|
||||
@@ -18,5 +18,8 @@ foreach test_file : test_sources
|
||||
)
|
||||
|
||||
# Add the executable as a test
|
||||
test(exe_name, test_exe)
|
||||
test(
|
||||
exe_name,
|
||||
test_exe,
|
||||
env: ['MESON_SOURCE_ROOT=' + meson.project_source_root(), 'MESON_BUILD_ROOT=' + meson.project_build_root()])
|
||||
endforeach
|
||||
|
||||
@@ -4,17 +4,16 @@ gtest_main = dependency('gtest_main', required: true)
|
||||
gtest_nomain_dep = dependency('gtest', main: false, required : true)
|
||||
|
||||
# Subdirectories for unit and integration tests
|
||||
subdir('dobj')
|
||||
subdir('const')
|
||||
subdir('meshIO')
|
||||
subdir('config')
|
||||
subdir('probe')
|
||||
subdir('config')
|
||||
subdir('eos')
|
||||
subdir('resource')
|
||||
subdir('network')
|
||||
subdir('composition')
|
||||
subdir('poly')
|
||||
|
||||
# Subdirectories for sandbox tests
|
||||
subdir('dobj_sandbox')
|
||||
subdir('composition_sandbox')
|
||||
|
||||
|
||||
@@ -14,13 +14,13 @@ class approx8Test : public ::testing::Test {};
|
||||
* @brief Test the constructor of the Config class.
|
||||
*/
|
||||
TEST_F(approx8Test, constructor) {
|
||||
Config& config = Config::getInstance();
|
||||
serif::config::Config& config = serif::config::Config::getInstance();
|
||||
config.loadConfig(TEST_CONFIG);
|
||||
EXPECT_NO_THROW(nnApprox8::Approx8Network());
|
||||
EXPECT_NO_THROW(serif::network::approx8::Approx8Network());
|
||||
}
|
||||
|
||||
TEST_F(approx8Test, setStiff) {
|
||||
nnApprox8::Approx8Network network;
|
||||
serif::network::approx8::Approx8Network network;
|
||||
EXPECT_NO_THROW(network.setStiff(true));
|
||||
EXPECT_TRUE(network.isStiff());
|
||||
EXPECT_NO_THROW(network.setStiff(false));
|
||||
@@ -28,8 +28,8 @@ TEST_F(approx8Test, setStiff) {
|
||||
}
|
||||
|
||||
TEST_F(approx8Test, evaluate) {
|
||||
nnApprox8::Approx8Network network;
|
||||
nuclearNetwork::NetIn netIn;
|
||||
serif::network::approx8::Approx8Network network;
|
||||
serif::network::NetIn netIn;
|
||||
|
||||
std::vector<double> comp = {0.708, 2.94e-5, 0.276, 0.003, 0.0011, 9.62e-3, 1.62e-3, 5.16e-4};
|
||||
|
||||
@@ -41,10 +41,10 @@ TEST_F(approx8Test, evaluate) {
|
||||
netIn.tmax = 3.15e17;
|
||||
netIn.dt0 = 1e12;
|
||||
|
||||
nuclearNetwork::NetOut netOut;
|
||||
serif::network::NetOut netOut;
|
||||
EXPECT_NO_THROW(netOut = network.evaluate(netIn));
|
||||
|
||||
EXPECT_DOUBLE_EQ(netOut.composition[nnApprox8::Net::ih1], 0.50166260916650918);
|
||||
EXPECT_DOUBLE_EQ(netOut.composition[nnApprox8::Net::ihe4],0.48172270591286032);
|
||||
EXPECT_DOUBLE_EQ(netOut.composition[serif::network::approx8::Net::ih1], 0.50166260916650918);
|
||||
EXPECT_DOUBLE_EQ(netOut.composition[serif::network::approx8::Net::ihe4],0.48172270591286032);
|
||||
EXPECT_DOUBLE_EQ(netOut.energy, 1.6433049870528356e+18);
|
||||
}
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
# Test files for dobj
|
||||
# Test files for const
|
||||
test_sources = [
|
||||
'MetadataTest.cpp',
|
||||
'DObjectTest.cpp',
|
||||
'LockableDObjectTest.cpp'
|
||||
'polyTest.cpp',
|
||||
]
|
||||
|
||||
foreach test_file : test_sources
|
||||
@@ -13,12 +11,13 @@ foreach test_file : test_sources
|
||||
test_exe = executable(
|
||||
exe_name,
|
||||
test_file,
|
||||
dependencies: [gtest_dep, gtest_main],
|
||||
include_directories: include_directories('../../src/dobj/public'),
|
||||
link_with: libdobj, # Link the dobj library
|
||||
dependencies: [gtest_dep, polysolver_dep, probe_dep, quill_dep, config_dep, gtest_main, resourceManager_dep],
|
||||
install_rpath: '@loader_path/../../src' # Ensure runtime library path resolves correctly
|
||||
)
|
||||
|
||||
# Add the executable as a test
|
||||
test(exe_name, test_exe)
|
||||
test(
|
||||
exe_name,
|
||||
test_exe,
|
||||
env: ['MESON_SOURCE_ROOT=' + meson.project_source_root(), 'MESON_BUILD_ROOT=' + meson.project_build_root()])
|
||||
endforeach
|
||||
55
tests/poly/polyTest.cpp
Normal file
55
tests/poly/polyTest.cpp
Normal file
@@ -0,0 +1,55 @@
|
||||
/* ***********************************************************************
|
||||
//
|
||||
// Copyright (C) 2025 -- The 4D-STAR Collaboration
|
||||
// File Author: Emily Boudreaux
|
||||
// Last Modified: March 18, 2025
|
||||
//
|
||||
// 4DSSE is free software; you can use it and/or modify
|
||||
// it under the terms and restrictions the GNU General Library Public
|
||||
// License version 3 (GPLv3) as published by the Free Software Foundation.
|
||||
//
|
||||
// 4DSSE is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
// See the GNU Library General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Library General Public License
|
||||
// along with this software; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
//
|
||||
// *********************************************************************** */
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
|
||||
#include "quill/LogMacros.h"
|
||||
#include "mfem.hpp"
|
||||
#include "polySolver.h"
|
||||
#include "probe.h"
|
||||
#include "config.h"
|
||||
|
||||
std::string CONFIG_FILENAME = std::string(getenv("MESON_SOURCE_ROOT")) + "/tests/testsConfig.yaml";
|
||||
|
||||
|
||||
class polyTest : public ::testing::Test {};
|
||||
|
||||
TEST_F(polyTest, Solve) {
|
||||
using namespace serif::polytrope;
|
||||
|
||||
serif::config::Config& config = serif::config::Config::getInstance();
|
||||
config.loadConfig(CONFIG_FILENAME);
|
||||
serif::probe::LogManager& logManager = serif::probe::LogManager::getInstance();
|
||||
quill::Logger* logger = logManager.getLogger("log");
|
||||
|
||||
|
||||
LOG_INFO(logger, "Starting polytrope solve test 1...");
|
||||
config.loadConfig(CONFIG_FILENAME);
|
||||
|
||||
double polytropicIndex = config.get<double>("Tests:Poly:Index", 1);
|
||||
LOG_INFO(logger, "Solving polytrope with n = {:0.2f}", polytropicIndex);
|
||||
|
||||
|
||||
PolySolver polytrope(polytropicIndex, 1);
|
||||
LOG_INFO(logger, "Solving polytrope...");
|
||||
EXPECT_NO_THROW(polytrope.solve());
|
||||
LOG_INFO(logger, "Polytrope solved.");
|
||||
}
|
||||
@@ -41,21 +41,21 @@ std::string stripTimestamps(const std::string& logLine) {
|
||||
class probeTest : public ::testing::Test {};
|
||||
|
||||
TEST_F(probeTest, DefaultConstructorTest) {
|
||||
Config::getInstance().loadConfig(TEST_CONFIG);
|
||||
EXPECT_NO_THROW(Probe::LogManager::getInstance());
|
||||
serif::config::Config::getInstance().loadConfig(TEST_CONFIG);
|
||||
EXPECT_NO_THROW(serif::probe::LogManager::getInstance());
|
||||
}
|
||||
|
||||
TEST_F(probeTest, waitTest) {
|
||||
auto start = std::chrono::high_resolution_clock::now();
|
||||
Probe::wait(1);
|
||||
serif::probe::wait(1);
|
||||
auto end = std::chrono::high_resolution_clock::now();
|
||||
std::chrono::duration<double> elapsed = end - start;
|
||||
EXPECT_LE(elapsed.count(), 1.1);
|
||||
}
|
||||
|
||||
TEST_F(probeTest, getLoggerTest) {
|
||||
Config::getInstance().loadConfig(TEST_CONFIG);
|
||||
Probe::LogManager& logManager = Probe::LogManager::getInstance();
|
||||
serif::config::Config::getInstance().loadConfig(TEST_CONFIG);
|
||||
serif::probe::LogManager& logManager = serif::probe::LogManager::getInstance();
|
||||
const std::string loggerName = "testLog";
|
||||
const std::string filename = "test.log";
|
||||
quill::Logger* logger = logManager.newFileLogger(filename, loggerName);
|
||||
@@ -70,8 +70,8 @@ TEST_F(probeTest, getLoggerTest) {
|
||||
}
|
||||
|
||||
TEST_F(probeTest, newFileLoggerTest) {
|
||||
Config::getInstance().loadConfig(TEST_CONFIG);
|
||||
Probe::LogManager& logManager = Probe::LogManager::getInstance();
|
||||
serif::config::Config::getInstance().loadConfig(TEST_CONFIG);
|
||||
serif::probe::LogManager& logManager = serif::probe::LogManager::getInstance();
|
||||
const std::string loggerName = "newLog";
|
||||
const std::string filename = "newLog.log";
|
||||
quill::Logger* logger = logManager.newFileLogger(filename, loggerName);
|
||||
@@ -86,8 +86,8 @@ TEST_F(probeTest, newFileLoggerTest) {
|
||||
}
|
||||
|
||||
TEST_F(probeTest, getLoggerNames) {
|
||||
Config::getInstance().loadConfig(TEST_CONFIG);
|
||||
Probe::LogManager& logManager = Probe::LogManager::getInstance();
|
||||
serif::config::Config::getInstance().loadConfig(TEST_CONFIG);
|
||||
serif::probe::LogManager& logManager = serif::probe::LogManager::getInstance();
|
||||
std::vector<std::string> loggerNames = logManager.getLoggerNames();
|
||||
EXPECT_EQ(loggerNames.size(), 4);
|
||||
EXPECT_EQ(loggerNames.at(0), "log");
|
||||
|
||||
@@ -11,7 +11,7 @@ foreach test_file : test_sources
|
||||
test_exe = executable(
|
||||
exe_name,
|
||||
test_file,
|
||||
dependencies: [gtest_dep, resourceManager_dep, gtest_main, macros_dep],
|
||||
dependencies: [gtest_dep, resourceManager_dep, gtest_main, macros_dep, opatio_dep],
|
||||
include_directories: include_directories('../../src/resource/public'),
|
||||
install_rpath: '@loader_path/../../src' # Ensure runtime library path resolves correctly
|
||||
)
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
#include <gtest/gtest.h>
|
||||
#include "resourceManager.h"
|
||||
#include "config.h"
|
||||
#include "EOSio.h"
|
||||
#include "helm.h"
|
||||
#include "resourceManager.h"
|
||||
#include "resourceManagerTypes.h"
|
||||
|
||||
#include <string>
|
||||
@@ -28,31 +28,31 @@ class resourceManagerTest : public ::testing::Test {};
|
||||
* @brief Test the constructor of the resourceManager class.
|
||||
*/
|
||||
TEST_F(resourceManagerTest, constructor) {
|
||||
Config::getInstance().loadConfig(TEST_CONFIG);
|
||||
EXPECT_NO_THROW(ResourceManager::getInstance());
|
||||
serif::config::Config::getInstance().loadConfig(TEST_CONFIG);
|
||||
EXPECT_NO_THROW(serif::resource::ResourceManager::getInstance());
|
||||
}
|
||||
|
||||
TEST_F(resourceManagerTest, getAvaliableResources) {
|
||||
Config::getInstance().loadConfig(TEST_CONFIG);
|
||||
ResourceManager& rm = ResourceManager::getInstance();
|
||||
std::vector<std::string> resources = rm.getAvaliableResources();
|
||||
serif::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:sphere"};
|
||||
std::set<std::string> actual(resources.begin(), resources.end());
|
||||
EXPECT_EQ(expected, actual);
|
||||
}
|
||||
|
||||
TEST_F(resourceManagerTest, getResource) {
|
||||
Config::getInstance().loadConfig(TEST_CONFIG);
|
||||
ResourceManager& rm = ResourceManager::getInstance();
|
||||
serif::config::Config::getInstance().loadConfig(TEST_CONFIG);
|
||||
serif::resource::ResourceManager& rm = serif::resource::ResourceManager::getInstance();
|
||||
std::string name = "eos:helm";
|
||||
const Resource &r = rm.getResource(name);
|
||||
const serif::resource::types::Resource &r = rm.getResource(name);
|
||||
// BREAKPOINT();
|
||||
const auto &eos = std::get<std::unique_ptr<EOSio>>(r);
|
||||
const auto &eos = std::get<std::unique_ptr<serif::eos::EOSio>>(r);
|
||||
EXPECT_EQ("helm", eos->getFormat());
|
||||
EOSTable &table = eos->getTable();
|
||||
serif::eos::EOSTable &table = eos->getTable();
|
||||
|
||||
// -- Extract the Helm table from the EOSTable
|
||||
helmholtz::HELMTable &helmTable = *std::get<std::unique_ptr<helmholtz::HELMTable>>(table);
|
||||
serif::eos::helmholtz::HELMTable &helmTable = *std::get<std::unique_ptr<serif::eos::helmholtz::HELMTable>>(table);
|
||||
EXPECT_DOUBLE_EQ(helmTable.f[0][0], -1692098915534.8142);
|
||||
|
||||
EXPECT_THROW(rm.getResource("opac:GS98:high:doesNotExist"), std::runtime_error);
|
||||
|
||||
@@ -3,15 +3,16 @@ Debug: true
|
||||
Probe:
|
||||
GLVis:
|
||||
Visualization: true
|
||||
# Host: "10.8.0.14"
|
||||
# Host: "10.28.92.45"
|
||||
Host: "localhost"
|
||||
Port: 19916
|
||||
DefaultKeyset: "iimmMMc"
|
||||
DefaultKeyset: "iimmMcaa"
|
||||
GetRaySolution:
|
||||
MakeDir: true
|
||||
Poly:
|
||||
Solver:
|
||||
ViewInitialGuess: true
|
||||
Epsilon: 1.0e-8
|
||||
ViewInitialGuess: false
|
||||
GMRES:
|
||||
MaxIter: 5000
|
||||
RelTol: 1.0e-8
|
||||
@@ -22,8 +23,10 @@ Poly:
|
||||
RelTol: 1.0e-8
|
||||
AbsTol: 1.0e-10
|
||||
PrintLevel: 1
|
||||
Newton:
|
||||
Constraint:
|
||||
Gamma: 1e2
|
||||
Output:
|
||||
View: true
|
||||
1D:
|
||||
Save: true
|
||||
Path: "output/Poly/1D/poly.csv"
|
||||
@@ -35,4 +38,4 @@ Poly:
|
||||
# ANY OPTIONS NEEDED FOR THE TEST SUITE SHOULD BE PLACED HERE
|
||||
Tests:
|
||||
Poly:
|
||||
Index: 1.1
|
||||
Index: 1.0
|
||||
Reference in New Issue
Block a user