diff --git a/src/lib/test/test-helper.cpp b/src/lib/test/test-helper.cpp index 401690788..0c67ca7fd 100644 --- a/src/lib/test/test-helper.cpp +++ b/src/lib/test/test-helper.cpp @@ -41,5 +41,21 @@ namespace test{ } + /** @todo probably this can be done in a more clever way. Anyone...? + */ + string + randStr (size_t len) + { + static const string alpha ("aaaabbccddeeeeffgghiiiijjkkllmmnnooooppqqrrssttuuuuvvwwxxyyyyzz0123456789"); + static const size_t MAXAL (alpha.size()); + + string garbage(len,'\0'); + size_t p = len; + while (p) + garbage[--p] = alpha[rand() % MAXAL]; + return garbage; + } + + }} // namespace lib::test diff --git a/src/lib/test/test-helper.hpp b/src/lib/test/test-helper.hpp index 26d3b5616..afa79c743 100644 --- a/src/lib/test/test-helper.hpp +++ b/src/lib/test/test-helper.hpp @@ -110,6 +110,11 @@ namespace test{ return Time (500 * (rand() % 2), (rand() % 600)); } + /** create garbage string of given length + * @return string containing arbitrary lower case letters and numbers + */ + string randStr (size_t len); + }} // namespace lib::test diff --git a/tests/40components.tests b/tests/40components.tests index a1013091e..f5d4d3d5e 100644 --- a/tests/40components.tests +++ b/tests/40components.tests @@ -489,6 +489,7 @@ END TEST "Test support functions" TestHelper_test < +#include #include +#include -using std::cout; -using std::endl; +using util::for_each; using lumiera::Error; using lumiera::LUMIERA_ERROR_EXCEPTION; using lumiera::error::LUMIERA_ERROR_ASSERTION; +using boost::algorithm::is_lower; +using boost::algorithm::is_digit; +using std::tr1::function; +using std::string; +using std::cout; +using std::endl; + namespace lib { namespace test{ @@ -61,6 +71,7 @@ namespace test{ void run (Arg) { + checkGarbageStr(); checkTypeDisplay(); checkThrowChecker(); } @@ -99,6 +110,24 @@ namespace test{ } + + + void + checkGarbageStr() + { + string garN = randStr(0); + ASSERT (0 == garN.size()); + + typedef function ChPredicate; + ChPredicate is_OK (is_lower() || is_digit()); + + string garM = randStr(1000000); + for_each (garM, is_OK); + + cout << randStr(80) << endl; + } + + /** @test check the VERIFY_ERROR macro, * which ensures a given error is raised. */