30 #include <boost/algorithm/string.hpp> 45 using std::string_literals::operator
""s;
46 using boost::algorithm::trim;
55 typedef map<string, Launcher*> TestMap;
56 typedef shared_ptr<TestMap> PTestMap;
57 typedef map<string,PTestMap> GroupMap;
78 getGroup (
string grpID)
80 return groups_[grpID];
84 add2group (
Launcher*
test,
string testID,
string groupID)
87 REQUIRE( !isnil(testID) );
88 REQUIRE( !isnil(groupID) );
90 PTestMap& group = getGroup(groupID);
92 group.reset(
new TestMap );
93 (*group)[testID] = test;
108 auto kind = fixedSeed?
"!fix" :
"rand";
109 NOTICE (
test,
" ++>>> SEED(%s) <<<: %s",
kind, toString(seed).c_str());
134 REQUIRE( !isnil(testID) );
136 std::istringstream ss(groups);
139 testcases.add2group(test, testID, group);
142 testcases.add2group(test,testID, ALLGROUP);
150 const int Suite::TEST_OK = 0;
162 REQUIRE( !isnil(groupID) );
163 TRACE(
test,
"Test-Suite( groupID=%s )\n", groupID.c_str () );
166 std::srand (std::time (
nullptr));
170 if (!testcases.getGroup(groupID))
176 Suite::getExitCode ()
const 183 #define IS_VALID(test,testID) \ 184 ASSERT ((test), "NULL testcase launcher for test '%s' found in testsuite '%s'", groupID_.c_str(),testID.c_str()); 190 invokeTestCase (
Test& theTest, Arg cmdline)
193 INFO (
test,
"++------------------- invoking TEST: %s",
cStr(typeStr (theTest)));
194 theTest.run (cmdline);
195 return Suite::TEST_OK;
200 cerr <<
"*** Test Failure " << theTest << endl;
201 cerr <<
"*** : " << failure.
what() << endl;
202 ERROR (
test,
"Error state %s", errorID);
203 WARN (progress,
"Caught exception %s", failure.
what());
228 someNumber = boost::lexical_cast<uint> (arg[1]);
235 return isnil(arg)? util::BOTTOM_INDICATOR
253 PTestMap tests = testcases.getGroup(groupID_);
257 if (0 < cmdline.size())
259 string& testID (cmdline[0]);
261 if ( contains (*tests, testID))
266 IS_VALID (test,testID);
270 if (1 == cmdline.size()) cmdline.clear();
272 exitCode_ |= invokeTestCase (*test->makeInstance(), cmdline);
281 for ( TestMap::iterator i=tests->begin(); i!=tests->end(); ++i )
283 cout <<
"\n ----------"<< i->first<<
"----------\n";
285 IS_VALID (test, i->first);
286 exitCode_ |= invokeTestCase (*test->makeInstance(), cmdline);
302 PTestMap tests = testcases.getGroup(groupID_);
305 cout <<
"TESTING \"Component Test Suite: " << groupID_ <<
"\" ./test-components\n\n";
307 for ( TestMap::iterator i=tests->begin(); i!=tests->end(); ++i )
309 string key (i->first);
311 cout <<
"TEST \""<<key<<
"\" "<<key<<
" <<END\n";
313 IS_VALID (test, i->first);
316 test->makeInstance()->run(noCmdline);
CStr cStr(std::string const &rendered)
convenience shortcut: forced conversion to c-String via string.
lib::Random makeRandGen()
build a dedicated new RandomGen, seeded from the default-Gen
Suite(string groupID, opt_uint64 seed)
create a suite comprised of all the testcases previously registered with this this group...
virtual CStr what() const noexcept override
std::exception interface : yield a diagnostic message
helper to collect and manage the test cases.
Random entropyGen
a global RandomSequencer seeded with real entropy
static const int EXCEPTION_THROWN
exit code returned when any individual test threw
SeedNucleus & seedFromDefaultGen()
draw seed another Generator from the default RandomSequencer
Derived specific exceptions within Lumiera's exception hierarchy.
Abstract Base Class for all testcases.
bool run(Arg cmdline)
run all testcases contained in this Suite.
Class to encapsulate the typical C-style commandline definition.
RandomSequencer< std::mt19937_64 > Random
PRNG engine to use by default: 64bit Mersenne twister.
Marker types to indicate a literal string and a Symbol.
Simplistic test class runner.
void seedRand()
draw a new random seed from a common nucleus, and re-seed the default-Gen.
static string firstTok(Arg)
conveniently pick the first token from the argument line
void reseed(SeedNucleus &)
inject controlled randomisation
Building and running a suite of tests, implemented as test classes.
Tiny helper functions and shortcuts to be used everywhere Consider this header to be effectively incl...
lumiera_err lumiera_error(void)
Get and clear current error state.
static const string ALLGROUP
"magic" groupID containing all registered testcases
uint64_t u64()
random 64bit number from full range.
Establishes a seed point for any instance or performance.
static uint firstVal(Arg, uint=1)
conveniently use some number given as argument, with optional default
interface: generic testcase creating functor.
Lumiera error handling (C++ interface).
Generating (pseudo) random numbers with controlled seed.
void describe()
print to stdout an enumeration of all testcases in this suite, in a format suitable for use with Ceht...
opt_uint64 fixedSeed
optionally a fixed random seed to inject in each invoked test
static void enrol(Launcher *test, string testID, string groups)
register the given test-launcher, so it can be later accessed either as a member of one of the specif...
Random defaultGen
a global default RandomSequencer for mundane purposes
Abstraction of the usual int argc, int** argv-Commandline, to be able to treat it as a vector of stri...
Interface and Base definition for all Lumiera Exceptions.
bool contains(SEQ const &cont, typename SEQ::const_reference val)
shortcut for brute-force containment test in any sequential container