summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--netfs/unittests/mockFuse.cpp14
-rw-r--r--netfs/unittests/mockFuse.h2
2 files changed, 16 insertions, 0 deletions
diff --git a/netfs/unittests/mockFuse.cpp b/netfs/unittests/mockFuse.cpp
index a1cf29b..0de5cf2 100644
--- a/netfs/unittests/mockFuse.cpp
+++ b/netfs/unittests/mockFuse.cpp
@@ -1,6 +1,7 @@
#include "mockFuse.h"
#include <boost/test/test_tools.hpp>
#include <buffer.h>
+#include <random>
FuseMock::FuseMock(std::string ep, Ice::StringSeq a) :
NetFS::FuseApp(std::move(a)), testEndpoint(std::move(ep)), context({})
@@ -36,6 +37,19 @@ FuseMock::connectToService()
}
}
+std::vector<char>
+FuseMock::genRandomData(size_t size)
+{
+ std::vector<char> buf(size);
+ std::generate(begin(buf), end(buf),
+ [dist = std::uniform_int_distribution<char>(
+ std::numeric_limits<char>::min(), std::numeric_limits<char>::max()),
+ mersenne_engine = std::mt19937(std::random_device()())]() mutable {
+ return dist(mersenne_engine);
+ });
+ return buf;
+}
+
void
FuseMock::vlogf(int, const char * fmt, va_list args) const noexcept
{
diff --git a/netfs/unittests/mockFuse.h b/netfs/unittests/mockFuse.h
index cb69816..7a380eb 100644
--- a/netfs/unittests/mockFuse.h
+++ b/netfs/unittests/mockFuse.h
@@ -1,6 +1,7 @@
#pragma once
#include <fuseApp.h>
+#include <vector>
#include <visibility.h>
class DLL_PUBLIC FuseMock : public NetFS::FuseApp {
@@ -11,6 +12,7 @@ public:
void vlogf(int, const char *, va_list) const throw() override;
void connectToService() override;
+ [[nodiscard]] static std::vector<char> genRandomData(size_t);
private:
const std::string testEndpoint;