aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArseny Kapoulkine <arseny.kapoulkine@gmail.com>2019-06-09 11:55:36 -0700
committerGitHub <noreply@github.com>2019-06-09 11:55:36 -0700
commitfcb7c8d3e5335c76bd2aa81f40a153f9b2b05647 (patch)
tree1b17051eb26371060d1eefdb26f1e439cc7c08c5
parent7247a823b72259a2b814696838d02f7424a8ce0e (diff)
parent86e0fe1980638599778377b3c151d070b9af04ef (diff)
downloadpugixml-fcb7c8d3e5335c76bd2aa81f40a153f9b2b05647.zip
pugixml-fcb7c8d3e5335c76bd2aa81f40a153f9b2b05647.tar.gz
pugixml-fcb7c8d3e5335c76bd2aa81f40a153f9b2b05647.tar.bz2
Merge pull request #276 from denchat/patch-1
std::random_shuffle is removed in current standard
-rw-r--r--tests/test_xpath.cpp12
1 files changed, 10 insertions, 2 deletions
diff --git a/tests/test_xpath.cpp b/tests/test_xpath.cpp
index fe1e312..b057c57 100644
--- a/tests/test_xpath.cpp
+++ b/tests/test_xpath.cpp
@@ -10,6 +10,14 @@
#include <algorithm>
#include <limits>
+// std::random_shuffle is deprecated in c++14, is removed in c++17.
+#if defined(__cplusplus) && (__cplusplus >= 201402L)
+# include <random>
+# define PUGIXML_SHUFFLE(rng) std::shuffle(rng.begin(), rng.end(), std::default_random_engine{std::random_device{}()})
+#else
+# define PUGIXML_SHUFFLE(rng) std::random_shuffle(rng.begin(), rng.end())
+#endif
+
using namespace pugi;
static void load_document_copy(xml_document& doc, const char_t* text)
@@ -155,7 +163,7 @@ TEST(xpath_sort_random_medium)
xpath_node_set ns = doc.select_nodes(STR("//node() | //@*"));
std::vector<xpath_node> nsv(ns.begin(), ns.end());
- std::random_shuffle(nsv.begin(), nsv.end());
+ PUGIXML_SHUFFLE(nsv);
xpath_node_set copy(&nsv[0], &nsv[0] + nsv.size());
copy.sort();
@@ -184,7 +192,7 @@ TEST(xpath_sort_random_large)
xpath_node_set ns = doc.select_nodes(STR("//node() | //@*"));
std::vector<xpath_node> nsv(ns.begin(), ns.end());
- std::random_shuffle(nsv.begin(), nsv.end());
+ PUGIXML_SHUFFLE(nsv);
xpath_node_set copy(&nsv[0], &nsv[0] + nsv.size());
copy.sort();