#include <vector>
#include <string>
#include <map>
+#include <random>
+
#include <assert.h>
#include <boost/lexical_cast.hpp>
static void print_gc_state();
- static std::vector<std::string> const & getTestStrings();
+ static std::vector<std::string> const& getTestStrings();
+
+ template <typename RandomIt>
+ void shuffle( RandomIt first, RandomIt last )
+ {
+ std::shuffle( first, last, m_RandomGen );
+ }
protected:
static std::vector<std::string> m_arrStrings ; // array of test strings
static std::string m_strTestDataDir;
static bool m_bExactMatch;
+ // random shuffle support
+ static std::random_device m_RandomDevice;
+ static std::mt19937 m_RandomGen;
+
protected:
static int m_numErrors;
static int m_numTests;
namespace CppUnitMini
{
- int TestCase::m_numErrors = 0;
- int TestCase::m_numTests = 0;
- std::vector<std::string> TestCase::m_arrStrings;
- bool TestCase::m_bPrintGCState = false;
- std::string TestCase::m_strTestDataDir(".");
- Config TestCase::m_Cfg;
- bool TestCase::m_bExactMatch = false;
-
- TestCase * TestCase::m_pCurTestCase = nullptr;
-
- TestCase *TestCase::m_root = 0;
- Reporter *TestCase::m_reporter = 0;
+ int TestCase::m_numErrors = 0;
+ int TestCase::m_numTests = 0;
+ std::vector<std::string> TestCase::m_arrStrings;
+ bool TestCase::m_bPrintGCState = false;
+ std::string TestCase::m_strTestDataDir(".");
+ Config TestCase::m_Cfg;
+ bool TestCase::m_bExactMatch = false;
+
+ // random shuffle support
+ /*static*/ std::random_device TestCase::m_RandomDevice;
+ /*static*/ std::mt19937 TestCase::m_RandomGen( TestCase::m_RandomDevice() );
+
+ TestCase * TestCase::m_pCurTestCase = nullptr;
+
+ TestCase *TestCase::m_root = 0;
+ Reporter *TestCase::m_reporter = 0;
void TestCase::registerTestCase(TestCase *in_testCase) {
in_testCase->m_next = m_root;
m_arrInsert[i] = i;
m_arrRemove[i] = i;
}
- std::random_shuffle( m_arrInsert.begin(), m_arrInsert.end() );
- std::random_shuffle( m_arrRemove.begin(), m_arrRemove.end() );
+ shuffle( m_arrInsert.begin(), m_arrInsert.end() );
+ shuffle( m_arrRemove.begin(), m_arrRemove.end() );
}
void Map_DelOdd::myRun(const char *in_name, bool invert /*= false*/)