summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2024-03-18 21:05:07 +0100
committerCarl Hetherington <cth@carlh.net>2024-03-20 18:25:09 +0100
commit15d7164347404249542dc5ae75cfd37011aef7c3 (patch)
treefcf67f82ded1e0b881370800f5cb9eee57773efa
parent055bdbca9582b43e2bd8d0373f35f37c9a2a73f8 (diff)
Replace std::random_shuffle (removed in C++17).
-rw-r--r--test/image_filename_sorter_test.cc9
1 files changed, 7 insertions, 2 deletions
diff --git a/test/image_filename_sorter_test.cc b/test/image_filename_sorter_test.cc
index eb662a120..29b550753 100644
--- a/test/image_filename_sorter_test.cc
+++ b/test/image_filename_sorter_test.cc
@@ -28,9 +28,10 @@
#include "lib/image_filename_sorter.h"
#include "lib/compose.hpp"
#include <boost/test/unit_test.hpp>
+#include <algorithm>
+#include <random>
-using std::random_shuffle;
using std::sort;
using std::vector;
@@ -69,7 +70,11 @@ BOOST_AUTO_TEST_CASE (image_filename_sorter_test2)
for (int i = 0; i < 100000; ++i) {
paths.push_back(String::compose("some.filename.with.%1.number.tiff", i));
}
- random_shuffle (paths.begin(), paths.end());
+
+ std::random_device rd;
+ std::mt19937 generator(rd());
+ std::shuffle(paths.begin(), paths.end(), generator);
+
sort (paths.begin(), paths.end(), ImageFilenameSorter());
for (int i = 0; i < 100000; ++i) {
BOOST_CHECK_EQUAL(paths[i].string(), String::compose("some.filename.with.%1.number.tiff", i));