SERiF 0.0.1a
3+1D Stellar Structure and Evolution
Loading...
Searching...
No Matches
resourceManagerTest.cpp
Go to the documentation of this file.
1#include <gtest/gtest.h>
2#include "config.h"
3#include "EOSio.h"
4#include "helm.h"
5#include "resourceManager.h"
7
8#include <string>
9#include <stdexcept>
10#include <vector>
11#include <set>
12
13#include "debug.h"
14
19
20
21std::string TEST_CONFIG = std::string(getenv("MESON_SOURCE_ROOT")) + "/tests/testsConfig.yaml";
25class resourceManagerTest : public ::testing::Test {};
26
31 serif::config::Config::getInstance().loadConfig(TEST_CONFIG);
33}
34
35TEST_F(resourceManagerTest, getAvaliableResources) {
36 serif::config::Config::getInstance().loadConfig(TEST_CONFIG);
38 std::vector<std::string> resources = rm.getAvailableResources();
39 std::set<std::string> expected = {"eos:helm", "mesh:polySphere"};
40 std::set<std::string> actual(resources.begin(), resources.end());
41 EXPECT_EQ(expected, actual);
42}
43
45 serif::config::Config::getInstance().loadConfig(TEST_CONFIG);
47 std::string name = "eos:helm";
49 // BREAKPOINT();
50 const auto &eos = std::get<std::unique_ptr<serif::eos::EOSio>>(r);
51 EXPECT_EQ("Helmholtz", eos->getFormatName());
52 serif::eos::EOSTable &table = eos->getTable();
53
54 // -- Extract the Helm table from the EOSTable
55 serif::eos::helmholtz::HELMTable &helmTable = *std::get<std::unique_ptr<serif::eos::helmholtz::HELMTable>>(table);
56 EXPECT_DOUBLE_EQ(helmTable.f[0][0], -1692098915534.8142);
57
58 EXPECT_THROW(rm.getResource("opac:GS98:high:doesNotExist"), std::runtime_error);
59}
60
61
Test suite for the resourceManager class.
const types::Resource & getResource(const std::string &name) const
Gets a resource by name.
std::vector< std::string > getAvailableResources() const
Gets a list of available resources.
static ResourceManager & getInstance()
Gets the singleton instance of the ResourceManager.
Defines a macro for triggering a breakpoint in different compilers and platforms.
std::string TEST_CONFIG
Definition eosTest.cpp:22
std::variant< std::unique_ptr< serif::eos::helmholtz::HELMTable > > EOSTable
Definition EOSio.h:38
std::variant< std::unique_ptr< opat::OPAT >, std::unique_ptr< serif::mesh::MeshIO >, std::unique_ptr< serif::eos::EOSio > > Resource
A variant type that can hold different types of resources.
TEST_F(resourceManagerTest, constructor)
Test the constructor of the resourceManager class.
Defines types and functions for managing resources.
Structure to hold the Helmholtz EOS table data.
Definition helm.h:63