summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2022-04-08 20:01:21 +0100
committerDan Goodliffe <dan@randomdan.homeip.net>2022-04-08 20:01:21 +0100
commit3cc9fd842f0fea43a03e34bf88e2b6de29b86ad4 (patch)
tree8d4d554f9ed80bc99a5537c819b7b66c70c747fe
parentMark constructor explicit (diff)
downloadnetfs-3cc9fd842f0fea43a03e34bf88e2b6de29b86ad4.tar.bz2
netfs-3cc9fd842f0fea43a03e34bf88e2b6de29b86ad4.tar.xz
netfs-3cc9fd842f0fea43a03e34bf88e2b6de29b86ad4.zip
Modern random
-rw-r--r--netfs/unittests/testEdgeCases.cpp11
1 files changed, 8 insertions, 3 deletions
diff --git a/netfs/unittests/testEdgeCases.cpp b/netfs/unittests/testEdgeCases.cpp
index 17dd706..2553a7f 100644
--- a/netfs/unittests/testEdgeCases.cpp
+++ b/netfs/unittests/testEdgeCases.cpp
@@ -3,6 +3,7 @@
#include "mockFuse.h"
#include <boost/test/unit_test.hpp>
#include <definedDirs.h>
+#include <random>
const std::string testEndpoint("tcp -h localhost -p 12014");
@@ -34,9 +35,13 @@ BOOST_AUTO_TEST_CASE(createAndDaemonRestart)
BOOST_TEST_CHECKPOINT("Write some data");
std::array<char, 890> someData {};
- for (auto & d : someData) {
- d = rand();
- }
+ std::generate(begin(someData), end(someData),
+ [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);
+ });
+
BOOST_REQUIRE_EQUAL(sizeof(someData), fuse.fuse->write(fileName, someData.data(), someData.size(), 0, &fh));
BOOST_REQUIRE_EQUAL(0, fuse.fuse->getattr(fileName, &st, &fh));