summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2024-02-26 22:48:37 +0000
committerDan Goodliffe <dan@randomdan.homeip.net>2024-02-26 22:48:37 +0000
commit6c13527020d65c410ee8daef18ee8273cdf8e827 (patch)
treed1ba14ccf6c968fdcccee15e6fb009f207e15766 /test
parentAdd read persistence support for tuple and pair (diff)
downloadilt-6c13527020d65c410ee8daef18ee8273cdf8e827.tar.bz2
ilt-6c13527020d65c410ee8daef18ee8273cdf8e827.tar.xz
ilt-6c13527020d65c410ee8daef18ee8273cdf8e827.zip
Add helper for loading fixtures for data tests from fixture JSON
Diffstat (limited to 'test')
-rw-r--r--test/testHelpers.h11
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_}; \