Skip to content
Snippets Groups Projects
Commit f2d4c4a2 authored by Dr. Felix Tobias Schindler's avatar Dr. Felix Tobias Schindler
Browse files

[test.common] add means to obtain current test id

parent 223876ff
No related branches found
No related tags found
No related merge requests found
......@@ -76,6 +76,20 @@ void busywait(const size_t ms);
namespace Dune {
namespace XT {
namespace Common {
namespace Test {
/**
* \sa DXTC_TEST_CONFIG_GET
* \sa DXTC_TEST_CONFIG_SET
* \sa DXTC_TEST_CONFIG_SUB
*/
std::string get_unique_test_name();
} // namespace Test
} // namespace Common
namespace Test {
namespace internal {
......@@ -193,4 +207,37 @@ ostream& operator<<(ostream& out, const map<F, S>& results)
} // namespace std
/**
* \brief Can be used to access the configuration assosicated with the currently running test
* \sa get_unique_test_name
*/
template <typename T>
static auto DXTC_TEST_CONFIG_GET(const std::string& key, T def) -> decltype(DXTC_CONFIG.get(key, def))
{
return DXTC_CONFIG.get(Dune::XT::Common::Test::get_unique_test_name() + "." + key, def);
}
/**
* \brief Can be used to access the configuration assosicated with the currently running test
* \sa get_unique_test_name
*/
template <typename T>
static void DXTC_TEST_CONFIG_SET(const std::string& key, T val)
{
return DXTC_CONFIG.set(Dune::XT::Common::Test::get_unique_test_name() + "." + key, val, /*overwrite=*/true);
}
/**
* \brief Can be used to access the configuration assosicated with the currently running test
* \sa get_unique_test_name
*/
static Dune::XT::Common::Configuration DXTC_TEST_CONFIG_SUB(const std::string& sub_key)
{
const auto key = Dune::XT::Common::Test::get_unique_test_name() + "." + sub_key;
EXPECT_TRUE(DXTC_CONFIG.has_sub(key));
return DXTC_CONFIG.sub(key);
}
#endif // DUNE_XT_COMMON_TEST_MAIN_COMMON_HH
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment