/* $Id$ */
-#ifndef _CPPUNITMPFR_H_
-#define _CPPUNITMPFR_H_
+#ifndef CDS_CPPUNIT_MPFR_H_
+#define CDS_CPPUNIT_MPFR_H_
#include <string.h>
#include <sstream>
#include <vector>
#include <string>
#include <map>
+#include <random>
+
#include <assert.h>
#include <boost/lexical_cast.hpp>
unsigned int getUInt( const char * pszParamName, unsigned int nDefVal = 0 ) const { return get( pszParamName, nDefVal ) ; }
long getLong( const char * pszParamName, long nDefVal = 0 ) const { return get( pszParamName, nDefVal ) ; }
unsigned long getULong( const char * pszParamName, unsigned long nDefVal = 0 ) const { return get( pszParamName, nDefVal ) ; }
+ size_t getSizeT( const char * pszParamName, size_t nDefVal = 0 ) const
+ {
+ return static_cast<size_t>( getULong( pszParamName, static_cast<unsigned long>(nDefVal)));
+ }
bool getBool( const char * pszParamName, bool bDefVal = false ) const
{
std::cerr << "bad_lexical_cast encountered while getting parameter "
<< strParamName << "=" << it->second
<< ": " << ex.what()
- << std::endl
-;
+ << std::endl;
}
return bDefVal;
}
class TestCase : public TestFixture {
public:
- TestCase() { registerTestCase(this); }
+ TestCase()
+ {
+ registerTestCase(this);
+ }
void setUp() { m_failed = false; }
static int run(Reporter *in_reporter = 0, const char *in_testName = "", bool invert = false);
m_reporter->error(in_macroName, in_macro, in_file, in_line);
}
}
+ virtual char const * test_name() const = 0;
static void message(const char *msg) {
if (m_reporter) {
}
}
- bool shouldRunThis(const char *in_desiredTest, const char *in_className, const char *in_functionName,
- bool invert, bool explicit_test, bool &do_progress) {
- if ((in_desiredTest) && (in_desiredTest[0] != '\0')) {
- do_progress = false;
- const char *ptr = strstr(in_desiredTest, "::");
- if (ptr) {
- bool match = (strncmp(in_desiredTest, in_className, strlen(in_className)) == 0 && in_desiredTest[strlen(in_className)] == ':' )
- && (strncmp(ptr + 2, in_functionName, strlen(ptr + 2)) == 0);
- // Invert shall not make explicit test run:
- return invert ? (match ? !match : !explicit_test)
- : match;
- }
- bool match = (strcmp(in_desiredTest, in_className) == 0);
- do_progress = match;
- return !explicit_test && (match == !invert);
- }
- do_progress = true;
- return !explicit_test;
- }
+ bool shouldRunThis( const char *in_desiredTest, const char *in_className, const char *in_functionName,
+ bool invert, bool explicit_test, bool &do_progress );
void tearDown() {
print_gc_state();
static void print_gc_state();
- static std::vector<std::string> const & getTestStrings();
+ static std::vector<std::string> const& getTestStrings();
+
+ template <typename RandomIt>
+ static void shuffle( RandomIt first, RandomIt last )
+ {
+ std::shuffle( first, last, m_RandomGen );
+ }
+
+ static void print_test_list();
protected:
static std::vector<std::string> m_arrStrings ; // array of test strings
public:
static bool m_bPrintGCState ; // print GC state after each test
static Config m_Cfg;
- static std::string m_strTestDataDir;
+ 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;
#define CPPUNIT_TEST_SUITE_(X, cfgBranchName) \
typedef CppUnitMini::TestCase Base; \
+ virtual char const * test_name() const { return #X; } \
virtual void myRun(const char *in_name, bool invert = false) { \
const char *className = #X; CPPUNIT_MINI_HIDE_UNUSED_VARIABLE(className) \
bool ignoring = false; CPPUNIT_MINI_HIDE_UNUSED_VARIABLE(ignoring) \
setUpParams( m_Cfg.get( cfgBranchName ));
-#define CPPUNIT_TEST_SUITE_PART(X, func) \
- void X::func(const char *in_name, bool invert /*= false*/) { \
- const char *className = #X; CPPUNIT_MINI_HIDE_UNUSED_VARIABLE(className) \
- bool ignoring = false; CPPUNIT_MINI_HIDE_UNUSED_VARIABLE(ignoring)
-
#define CPPUNIT_TEST_SUITE(X) CPPUNIT_TEST_SUITE_(X, #X)
#if defined CPPUNIT_MINI_USE_EXCEPTIONS
X(); \
} \
catch(...) { \
- Base::error("Test Failed: An Exception was thrown.", #X, __FILE__, __LINE__); \
+ Base::error("Test Failed: An exception was thrown.", #X, __FILE__, __LINE__); \
} \
} \
tearDown(); \
#define CPPUNIT_TEST(X) CPPUNIT_TEST_BASE(X, false)
#define CPPUNIT_EXPLICIT_TEST(X) CPPUNIT_TEST_BASE(X, true)
+#define CDSUNIT_DECLARE_TEST(X) void X();
+
#define CPPUNIT_IGNORE \
ignoring = true
#define CPPUNIT_TEST_SUITE_END() endTestCase(); }
#define CPPUNIT_TEST_SUITE_END_PART() }
-#define CPPUNIT_TEST_SUITE_REGISTRATION(X) static X local
#define CPPUNIT_TEST_SUITE_REGISTRATION_(X, NAME) static X NAME
+#define CPPUNIT_TEST_SUITE_REGISTRATION(X) CPPUNIT_TEST_SUITE_REGISTRATION_(X, local)
#define CPPUNIT_CHECK(X) \
if (!(X)) { \
error( "CPPUNIT_ASSERT_MSG", st.str().c_str(), __FILE__, __LINE__ ) ; \
}
-#endif
+#endif // #ifndef CDS_CPPUNIT_MPFR_H_