From 2c94e0226043393af81f03e6276951b4111a4cf4 Mon Sep 17 00:00:00 2001 From: IlushaShurupov Date: Fri, 30 Jun 2023 09:07:48 +0300 Subject: [PATCH] Testing removing dublicated reports --- TODO | 5 +++-- Utils/private/Testing.cpp | 12 ++++++++++-- Utils/public/Testing.hpp | 3 ++- 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/TODO b/TODO index 8d70f64..55e2446 100644 --- a/TODO +++ b/TODO @@ -1,9 +1,9 @@ Containers: - ADd check copy times + ADd check copy times ! Addbuff Vector Vector 2d - AVL dont copy data just swap + AVL dont copy data just swap ! Strings: Implement @@ -12,6 +12,7 @@ Math: Implement Utils: + Group failed checks by source !! Stack trace fixes Tokenizer: diff --git a/Utils/private/Testing.cpp b/Utils/private/Testing.cpp index 63b75e7..ae5ed46 100644 --- a/Utils/private/Testing.cpp +++ b/Utils/private/Testing.cpp @@ -22,7 +22,13 @@ void Testing::endTest() { } void Testing::addFailedCheck(const FailedCheck& info) { - mCurrent->mFailedChecks.pushBack(info); + DEBUG_BREAK(0 && info.expression); + auto lastRecord = &mCurrent->mFailedChecks.last()->data; + if (lastRecord && lastRecord->failedCheck.file == info.file && lastRecord->failedCheck.line == info.line) { + lastRecord->times++; + return; + } + mCurrent->mFailedChecks.pushBack({ info, 1 }); } void Testing::reportState() { @@ -58,7 +64,9 @@ void Testing::TestingNode::report(const char* path) const { auto newPath = path ? std::string(path) + "/" + mName : std::string(mName); for (auto check : mFailedChecks) { - printf("%s Failed - (%s) %s:%llu\n", newPath.c_str(), check.data().expression, check.data().file, check.data().line); + auto failedCheck = &check.data().failedCheck; + auto times = check.data().times; + printf("%s Failed - (%s) %s:%llu x%i\n", newPath.c_str(), failedCheck->expression, failedCheck->file, failedCheck->line, (halni) times); } for (const auto& child : mSubTests) { diff --git a/Utils/public/Testing.hpp b/Utils/public/Testing.hpp index 9567513..d6e59b8 100644 --- a/Utils/public/Testing.hpp +++ b/Utils/public/Testing.hpp @@ -23,7 +23,8 @@ namespace tp { private: struct TestingNode { - List mFailedChecks; + struct FailedCheckRecord { FailedCheck failedCheck; ualni times; }; + List mFailedChecks; List mSubTests; const char* mName = "Unnamed"; TestingNode* mParent = nullptr;