diff options
author | Dan Goodliffe <dan@randomdan.homeip.net> | 2024-02-26 22:48:37 +0000 |
---|---|---|
committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2024-02-26 22:48:37 +0000 |
commit | 6c13527020d65c410ee8daef18ee8273cdf8e827 (patch) | |
tree | d1ba14ccf6c968fdcccee15e6fb009f207e15766 | |
parent | Add read persistence support for tuple and pair (diff) | |
download | ilt-6c13527020d65c410ee8daef18ee8273cdf8e827.tar.bz2 ilt-6c13527020d65c410ee8daef18ee8273cdf8e827.tar.xz ilt-6c13527020d65c410ee8daef18ee8273cdf8e827.zip |
Add helper for loading fixtures for data tests from fixture JSON
-rw-r--r-- | test/testHelpers.h | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/test/testHelpers.h b/test/testHelpers.h index f2b0901..58e4372 100644 --- a/test/testHelpers.h +++ b/test/testHelpers.h @@ -2,11 +2,22 @@ #include <boost/test/tools/context.hpp> #include <boost/test/tools/interface.hpp> +#include <filesystem> +#include <fstream> #include <iomanip> // IWYU pragma: keep std::setprecision +#include <jsonParse-persistence.h> #include <memory> std::unique_ptr<char, decltype(&free)> uasprintf(const char * fmt, ...) __attribute__((format(printf, 1, 2))); +template<typename T> +decltype(auto) +loadFixtureJson(const std::filesystem::path & path) +{ + std::ifstream in {FIXTURESDIR / path}; + return Persistence::JsonParsePersistence {}.loadState<std::vector<T>>(in); +} + #define BOOST_CHECK_CLOSE_VEC(a_, b_) \ { \ const auto a {a_}, b {b_}; \ |