travis: fix clang
[awesomized/libmemcached] / testing / lib / random.cpp
index a238c743dd3c71bc3f823159db0ce6f220dc75d1..dbb3070340129ed2fb467443196502b0321a0e32 100644 (file)
@@ -1,24 +1,8 @@
 #include "testing/lib/random.hpp"
 #include "testing/lib/Connection.hpp"
 
-#include <chrono>
-#include <random>
-
 #include <unistd.h> // getpid()
 
-
-template<typename T>
-enable_if_t<is_integral_v<T>, T> random_num(T min, T max) {
-  using namespace chrono;
-  using rnd = mt19937;
-  using dst = uniform_int_distribution<T>;
-
-  auto time = duration_cast<microseconds>(system_clock::now().time_since_epoch());
-  auto seed = static_cast<rnd::result_type>(time.count() % numeric_limits<T>::max());
-  auto rgen = rnd{seed};
-  return dst(min, max)(rgen);
-}
-
 unsigned random_port() {
   retry:
   auto port = random_num(2<<9, 2<<15);
@@ -33,6 +17,10 @@ unsigned random_port() {
   goto retry;
 }
 
+string random_port_string(const string &) {
+  return to_string(random_port());
+}
+
 string random_socket(const string &prefix) {
   return prefix + to_string(random_num(1U, UINT32_MAX)) + "@" + to_string(getpid()) + ".sock";
 }
@@ -74,4 +62,3 @@ pair<string, string> random_ascii_pair(size_t minlen, size_t maxlen) {
       random_ascii_string(random_num(minlen, maxlen))
   };
 }
-