update src and test

This commit is contained in:
QIDI TECH
2025-03-22 09:44:19 +08:00
parent b15deeb656
commit 7e7d699e43
151 changed files with 36981 additions and 1531 deletions

View File

@@ -4,46 +4,53 @@
#define CATCH_CONFIG_EXTERNAL_INTERFACES
#define CATCH_CONFIG_MAIN
// #define CATCH_CONFIG_DEFAULT_REPORTER "verboseconsole"
#include <catch2/catch.hpp>
#include <catch2/reporters/catch_reporter_streaming_base.hpp>
#include <catch2/catch_all.hpp>
namespace Catch {
struct VerboseConsoleReporter : public ConsoleReporter {
struct VerboseConsoleReporter : public StreamingReporterBase {
double duration = 0.;
using ConsoleReporter::ConsoleReporter;
using StreamingReporterBase::StreamingReporterBase;
static std::string getDescription() {
return "Verbose Console Reporter";
}
void testCaseStarting(TestCaseInfo const& _testInfo) override
{
Colour::use(Colour::Cyan);
stream << "Testing ";
Colour::use(Colour::None);
stream << _testInfo.name << std::endl;
ConsoleReporter::testCaseStarting(_testInfo);
//Colour::use(Colour::Cyan);
m_stream << "Testing ";
//Colour::use(Colour::None);
m_stream << _testInfo.name << std::endl;
StreamingReporterBase::testCaseStarting(_testInfo);
}
void sectionStarting(const SectionInfo &_sectionInfo) override
{
if (_sectionInfo.name != currentTestCaseInfo->name)
stream << _sectionInfo.name << std::endl;
m_stream << _sectionInfo.name << std::endl;
ConsoleReporter::sectionStarting(_sectionInfo);
StreamingReporterBase::sectionStarting(_sectionInfo);
}
void sectionEnded(const SectionStats &_sectionStats) override {
duration += _sectionStats.durationInSeconds;
ConsoleReporter::sectionEnded(_sectionStats);
StreamingReporterBase::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;
//Colour::use(Colour::BrightGreen);
m_stream << "Passed";
//Colour::use(Colour::None);
m_stream << " in " << duration << " [seconds]\n" << std::endl;
}
duration = 0.;
ConsoleReporter::testCaseEnded(stats);
StreamingReporterBase::testCaseEnded(stats);
}
};