2019-10-29 12:33:29 +00:00
|
|
|
#ifndef CATCH_MAIN
|
|
|
|
#define CATCH_MAIN
|
|
|
|
|
|
|
|
#define CATCH_CONFIG_EXTERNAL_INTERFACES
|
|
|
|
#define CATCH_CONFIG_MAIN
|
2019-10-30 09:47:04 +00:00
|
|
|
#define CATCH_CONFIG_DEFAULT_REPORTER "verboseconsole"
|
2019-10-29 12:33:29 +00:00
|
|
|
#include <catch2/catch.hpp>
|
|
|
|
|
|
|
|
namespace Catch {
|
|
|
|
struct VerboseConsoleReporter : public ConsoleReporter {
|
|
|
|
double duration = 0.;
|
|
|
|
using ConsoleReporter::ConsoleReporter;
|
|
|
|
|
|
|
|
void testCaseStarting(TestCaseInfo const& _testInfo) override
|
|
|
|
{
|
|
|
|
Colour::use(Colour::Cyan);
|
|
|
|
stream << "Testing ";
|
|
|
|
Colour::use(Colour::None);
|
|
|
|
stream << _testInfo.name << std::endl;
|
|
|
|
ConsoleReporter::testCaseStarting(_testInfo);
|
|
|
|
}
|
|
|
|
|
|
|
|
void sectionStarting(const SectionInfo &_sectionInfo) override
|
|
|
|
{
|
|
|
|
if (_sectionInfo.name != currentTestCaseInfo->name)
|
|
|
|
stream << _sectionInfo.name << std::endl;
|
|
|
|
|
|
|
|
ConsoleReporter::sectionStarting(_sectionInfo);
|
|
|
|
}
|
|
|
|
|
|
|
|
void sectionEnded(const SectionStats &_sectionStats) override {
|
|
|
|
duration += _sectionStats.durationInSeconds;
|
|
|
|
ConsoleReporter::sectionEnded(_sectionStats);
|
|
|
|
}
|
|
|
|
|
|
|
|
void testCaseEnded(TestCaseStats const& stats) override
|
|
|
|
{
|
|
|
|
if (stats.totals.assertions.allOk()) {
|
|
|
|
Colour::use(Colour::BrightGreen);
|
|
|
|
stream << "Passed";
|
|
|
|
Colour::use(Colour::None);
|
|
|
|
stream << " in " << duration << " [seconds]\n" << std::endl;
|
|
|
|
}
|
|
|
|
|
|
|
|
duration = 0.;
|
|
|
|
ConsoleReporter::testCaseEnded(stats);
|
|
|
|
}
|
|
|
|
};
|
2019-10-30 09:47:04 +00:00
|
|
|
|
2019-10-29 12:33:29 +00:00
|
|
|
CATCH_REGISTER_REPORTER( "verboseconsole", VerboseConsoleReporter )
|
2019-10-30 09:47:04 +00:00
|
|
|
|
|
|
|
} // namespace Catch
|
2019-10-29 12:33:29 +00:00
|
|
|
|
|
|
|
#endif // CATCH_MAIN
|