TestSuite: Allow that verbose messages are reported in a test

This commit is contained in:
Daniel Marjamäki 2018-07-26 09:15:33 +02:00
parent c666f74755
commit fc5d8e5082
2 changed files with 8 additions and 3 deletions

View File

@ -73,7 +73,8 @@ std::size_t TestFixture::succeeded_todos_counter = 0;
std::set<std::string> TestFixture::missingLibs;
TestFixture::TestFixture(const char * const _name)
:quiet_tests(false),
:mVerbose(false),
quiet_tests(false),
classname(_name)
{
TestRegistry::theInstance().addTest(this);
@ -329,7 +330,7 @@ void TestFixture::reportOut(const std::string & outmsg)
void TestFixture::reportErr(const ErrorLogger::ErrorMessage &msg)
{
const std::string errormessage(msg.toString(false));
const std::string errormessage(msg.toString(mVerbose));
if (errout.str().find(errormessage) == std::string::npos)
errout << errormessage << std::endl;
}

View File

@ -37,6 +37,7 @@ private:
static std::size_t todos_counter;
static std::size_t succeeded_todos_counter;
static std::set<std::string> missingLibs;
bool mVerbose;
protected:
std::string testToRun;
@ -66,6 +67,9 @@ protected:
void complainMissingLib(const char * const libname) const;
std::string deleteLineNumber(const std::string &message) const;
void setVerbose(bool v) {
mVerbose = v;
}
void processOptions(const options& args);
public:
@ -83,7 +87,7 @@ public:
extern std::ostringstream errout;
extern std::ostringstream output;
#define TEST_CASE( NAME ) if ( prepareTest(#NAME) ) { NAME(); }
#define TEST_CASE( NAME ) if ( prepareTest(#NAME) ) { setVerbose(false); NAME(); }
#define ASSERT( CONDITION ) assert_(__FILE__, __LINE__, CONDITION)
#define ASSERT_EQUALS( EXPECTED , ACTUAL ) assertEquals(__FILE__, __LINE__, EXPECTED, ACTUAL)
#define ASSERT_EQUALS_WITHOUT_LINENUMBERS( EXPECTED , ACTUAL ) assertEqualsWithoutLineNumbers(__FILE__, __LINE__, EXPECTED, ACTUAL)