Files
QIDISlicer/tests/catch_main.hpp

62 lines
1.8 KiB
C++
Raw Normal View History

2023-06-10 10:14:12 +08:00
#ifndef CATCH_MAIN
#define CATCH_MAIN
#define CATCH_CONFIG_EXTERNAL_INTERFACES
#define CATCH_CONFIG_MAIN
// #define CATCH_CONFIG_DEFAULT_REPORTER "verboseconsole"
2025-03-22 09:44:19 +08:00
#include <catch2/reporters/catch_reporter_streaming_base.hpp>
#include <catch2/catch_all.hpp>
2023-06-10 10:14:12 +08:00
namespace Catch {
2025-03-22 09:44:19 +08:00
struct VerboseConsoleReporter : public StreamingReporterBase {
2023-06-10 10:14:12 +08:00
double duration = 0.;
2025-03-22 09:44:19 +08:00
using StreamingReporterBase::StreamingReporterBase;
static std::string getDescription() {
return "Verbose Console Reporter";
}
2023-06-10 10:14:12 +08:00
void testCaseStarting(TestCaseInfo const& _testInfo) override
{
2025-03-22 09:44:19 +08:00
//Colour::use(Colour::Cyan);
m_stream << "Testing ";
//Colour::use(Colour::None);
m_stream << _testInfo.name << std::endl;
StreamingReporterBase::testCaseStarting(_testInfo);
2023-06-10 10:14:12 +08:00
}
void sectionStarting(const SectionInfo &_sectionInfo) override
{
if (_sectionInfo.name != currentTestCaseInfo->name)
2025-03-22 09:44:19 +08:00
m_stream << _sectionInfo.name << std::endl;
2023-06-10 10:14:12 +08:00
2025-03-22 09:44:19 +08:00
StreamingReporterBase::sectionStarting(_sectionInfo);
2023-06-10 10:14:12 +08:00
}
void sectionEnded(const SectionStats &_sectionStats) override {
duration += _sectionStats.durationInSeconds;
2025-03-22 09:44:19 +08:00
StreamingReporterBase::sectionEnded(_sectionStats);
2023-06-10 10:14:12 +08:00
}
void testCaseEnded(TestCaseStats const& stats) override
{
if (stats.totals.assertions.allOk()) {
2025-03-22 09:44:19 +08:00
//Colour::use(Colour::BrightGreen);
m_stream << "Passed";
//Colour::use(Colour::None);
m_stream << " in " << duration << " [seconds]\n" << std::endl;
2023-06-10 10:14:12 +08:00
}
duration = 0.;
2025-03-22 09:44:19 +08:00
StreamingReporterBase::testCaseEnded(stats);
2023-06-10 10:14:12 +08:00
}
};
CATCH_REGISTER_REPORTER( "verboseconsole", VerboseConsoleReporter )
} // namespace Catch
#endif // CATCH_MAIN