/*
This file is a part of libcds - Concurrent Data Structures library
- (C) Copyright Maxim Khizhinsky (libcds.dev@gmail.com) 2006-2016
+ (C) Copyright Maxim Khizhinsky (libcds.dev@gmail.com) 2006-2017
Source code repo: http://github.com/khizmax/libcds/
Download: http://sourceforge.net/projects/libcds/files/
#include <algorithm>
#include <random>
+// earlier version of gtest do not support 4th parameter in INSTANTIATE_TEST_CASE_P macro
+//TODO: how to known gtest version?..
+//#define CDSTEST_GTEST_INSTANTIATE_TEST_CASE_P_HAS_4TH_ARG
+
namespace cds_test {
class fixture : public ::testing::Test
static void shuffle( RandomIt first, RandomIt last )
{
static std::random_device random_dev;
- static std::mt19937 random_gen( random_dev() );
+ static std::mt19937 random_gen( random_dev());
std::shuffle( first, last, random_gen );
}
+
+ static inline unsigned int rand( unsigned int nMax )
+ {
+ double rnd = double( std::rand()) / double( RAND_MAX );
+ unsigned int n = (unsigned int)(rnd * nMax);
+ return n < nMax ? n : (n - 1);
+ }
};
} // namespace cds_test