initial port for Cevo game in C++ (libs)

This commit is contained in:
Geoffray Levasseur committed 2026-10-22 17:20:45 +02:00
commit 8436242032
375 files changed
+46282

No files matched your search

+47
View File
@@ -0,0 +1,47 @@
#include "Cevo/TestCase.h"
#include <QCoreApplication>
#include <QDebug>
namespace Cevo {
QString testResultText(TestResult result)
{
switch (result) {
case TestResult::None:
return QCoreApplication::translate("TestCase", "None");
case TestResult::Passed:
return QCoreApplication::translate("TestCase", "Passed");
case TestResult::Failed:
return QCoreApplication::translate("TestCase", "Failed");
}
return {};
}
TestCase *TestCases::addNew(const QString &name, std::unique_ptr<TestCase> testCase)
{
testCase->name = name;
TestCase *result = testCase.get();
m_items.push_back(std::move(testCase));
return result;
}
void TestCases::run()
{
int passed = 0, failed = 0;
for (const auto &testCase : m_items) {
qDebug().noquote() << "== " << testCase->name << " ======= ";
testCase->initialize();
testCase->run();
testCase->finalize();
if (testCase->testResult == TestResult::Passed)
++passed;
else if (testCase->testResult == TestResult::Failed)
++failed;
}
for (const auto &testCase : m_items)
qDebug().noquote() << testCase->name << ": " << testResultText(testCase->testResult);
qDebug().noquote() << "Total: " << count() << ", Passed: " << passed << ", Failed: " << failed;
}
} // namespace Cevo