mirror of
https://github.com/ToruNiina/toml11.git
synced 2025-09-17 17:58:09 +08:00
Factor redundant test boilerplate out into unit_test.hpp helper
This commit is contained in:
23
tests/unit_test.hpp
Normal file
23
tests/unit_test.hpp
Normal file
@@ -0,0 +1,23 @@
|
||||
#ifndef BOOST_TEST_MODULE
|
||||
# error "Please #define BOOST_TEST_MODULE before you #include <unit_test.hpp>"
|
||||
#endif
|
||||
|
||||
#ifdef UNITTEST_FRAMEWORK_LIBRARY_EXIST
|
||||
# include <boost/test/unit_test.hpp>
|
||||
#else
|
||||
# include <boost/test/included/unit_test.hpp>
|
||||
#endif
|
||||
|
||||
#include <cstdlib>
|
||||
#include <string>
|
||||
|
||||
static inline auto testinput(const std::string& basename) -> std::string
|
||||
{
|
||||
const auto this_or_that = [](const char *const s, const char *const t) { return s ? s : t; };
|
||||
std::string directory = this_or_that(std::getenv("TOMLDIR"), "toml");
|
||||
if (!directory.empty() && directory.back() != '/')
|
||||
{
|
||||
directory.push_back('/');
|
||||
}
|
||||
return directory.append("tests/").append(basename);
|
||||
}
|
Reference in New Issue
Block a user