30#include <boost/algorithm/string.hpp>
44 using std::shared_ptr;
45 using std::string_literals::operator
""s;
46 using boost::algorithm::trim;
80 return groups_[grpID];
87 REQUIRE( !isnil(testID) );
88 REQUIRE( !isnil(groupID) );
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);
162 REQUIRE( !isnil(groupID) );
163 TRACE(
test,
"Test-Suite( groupID=%s )\n", groupID.c_str () );
166 std::srand (std::time (
nullptr));
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());
193 INFO (
test,
"++------------------- invoking TEST: %s",
cStr(typeStr (theTest)));
194 theTest.
run (cmdline);
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
257 if (0 < cmdline.size())
259 string& testID (cmdline[0]);
261 if ( contains (*tests, 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";
286 exitCode_ |= invokeTestCase (*
test->makeInstance(), cmdline);
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";
316 test->makeInstance()->run(noCmdline);
Abstraction of the usual int argc, int** argv-Commandline, to be able to treat it as a vector of stri...
uint64_t u64()
random 64bit number from full range.
void reseed(SeedNucleus &)
inject controlled randomisation
Establishes a seed point for any instance or performance.
Interface and Base definition for all Lumiera Exceptions.
virtual CStr what() const noexcept override
std::exception interface : yield a diagnostic message
interface: generic testcase creating functor.
void describe()
print to stdout an enumeration of all testcases in this suite, in a format suitable for use with Ceht...
static const int EXCEPTION_THROWN
exit code returned when any individual test threw
Suite(string groupID, opt_uint64 seed)
create a suite comprised of all the testcases previously registered with this this group.
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...
static const string ALLGROUP
"magic" groupID containing all registered testcases
bool run(Arg cmdline)
run all testcases contained in this Suite.
Abstract Base Class for all testcases.
virtual void run(Arg arg)=0
lib::Random makeRandGen()
build a dedicated new RandomGen, seeded from the default-Gen
static uint firstVal(Arg, uint=1)
conveniently use some number given as argument, with optional default
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
helper to collect and manage the test cases.
PTestMap & getGroup(string grpID)
void add2group(Launcher *test, string testID, string groupID)
opt_uint64 fixedSeed
optionally a fixed random seed to inject in each invoked test
uint64_t getSeed() override
Class to encapsulate the typical C-style commandline definition.
lumiera_err lumiera_error(void)
Get and clear current error state.
Lumiera error handling (C++ interface).
SeedNucleus & seedFromDefaultGen()
draw seed another Generator from the default RandomSequencer
Random entropyGen
a global RandomSequencer seeded with real entropy
Random defaultGen
a global default RandomSequencer for mundane purposes
LumieraError< LERR_(INVALID)> Invalid
int invokeTestCase(Test &theTest, Arg cmdline)
SuiteSeedNucleus suiteSeed
Test runner and basic definitions for tests.
map< string, PTestMap > GroupMap
shared_ptr< TestMap > PTestMap
map< string, Launcher * > TestMap
std::vector< string > & Arg
std::optional< uint64_t > opt_uint64
bool contains(MAP &map, typename MAP::key_type const &key)
shortcut for containment test on a map
std::string toString(TY const &val) noexcept
get some string representation of any object, reliably.
bool isnil(lib::time::Duration const &dur)
Generating (pseudo) random numbers with controlled seed.
Simplistic test class runner.
#define IS_VALID(test, testID)
Building and running a suite of tests, implemented as test classes.
Marker types to indicate a literal string and a Symbol.
CStr cStr(std::string const &rendered)
convenience shortcut: forced conversion to c-String via string.
Tiny helper functions and shortcuts to be used everywhere Consider this header to be effectively incl...