summaryrefslogtreecommitdiff
path: root/test/test-util.hpp
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2025-08-25 15:18:41 +0100
committerDan Goodliffe <dan@randomdan.homeip.net>2025-08-25 16:02:51 +0100
commit3d6c2f43932bf8930ea0b1a53f6ebe048c7803bc (patch)
tree11916da8f6dcd75c461a7c5cca075ca0fdeaf8d6 /test/test-util.hpp
parent6e549d226b0ebce6ecdce0e7c5f03a0ce4867a89 (diff)
downloadwebstat-3d6c2f43932bf8930ea0b1a53f6ebe048c7803bc.tar.bz2
webstat-3d6c2f43932bf8930ea0b1a53f6ebe048c7803bc.tar.xz
webstat-3d6c2f43932bf8930ea0b1a53f6ebe048c7803bc.zip
Move common test code to its own library
Diffstat (limited to 'test/test-util.hpp')
-rw-r--r--test/test-util.hpp24
1 files changed, 24 insertions, 0 deletions
diff --git a/test/test-util.hpp b/test/test-util.hpp
new file mode 100644
index 0000000..20020f8
--- /dev/null
+++ b/test/test-util.hpp
@@ -0,0 +1,24 @@
+#pragma once
+
+#include "pq-mock.h"
+#include <filesystem>
+
+namespace WebStat {
+#define XSTR(s) STR(s)
+#define STR(s) #s
+ inline const std::filesystem::path SRC_DIR(XSTR(SRC));
+#undef XSTR
+#undef STR
+
+ template<auto Deleter>
+ using DeleteWith = decltype([](auto obj) {
+ return Deleter(obj);
+ });
+ using FilePtr = std::unique_ptr<std::FILE, DeleteWith<&fclose>>;
+
+ struct MockDB : public DB::PluginMock<PQ::Mock> {
+ MockDB();
+ };
+
+ template<typename Out> using ParseData = std::tuple<std::string_view, Out>;
+}