From 3e931000eeea143ca84e8245b9cb0ed3a17b400e Mon Sep 17 00:00:00 2001 From: Denis Roussel Date: Sun, 11 Aug 2024 11:50:48 +0200 Subject: [PATCH] [IMP] Tests: Remove unwanted comments and manage strings messages without wxString --- src/tests/GOTestExe.cpp | 2 +- src/tests/common/GOTestCollection.cpp | 5 ----- src/tests/common/GOTestCollection.h | 1 - src/tests/common/GOTestException.h | 10 +++++----- src/tests/common/GOTestResult.cpp | 10 +++++++--- src/tests/common/GOTestResult.h | 13 ++++--------- src/tests/common/GOTestUtils.h | 2 +- src/tests/testing/model/GOTestOrganModel.cpp | 2 +- src/tests/testing/model/GOTestSwitch.cpp | 2 +- src/tests/testing/model/GOTestWindchest.cpp | 2 +- 10 files changed, 21 insertions(+), 28 deletions(-) diff --git a/src/tests/GOTestExe.cpp b/src/tests/GOTestExe.cpp index 8c6ea9fa4..6152bfed4 100644 --- a/src/tests/GOTestExe.cpp +++ b/src/tests/GOTestExe.cpp @@ -36,7 +36,7 @@ int main() { ++current, ++run_number_) { auto test_result = *current; wxLogMessage("-------------------------------------------------------"); - wxLogMessage(test_result->GetMessage()); + wxLogMessage(wxString(test_result->GetMessage())); } const int failed_count = GOTestCollection::Instance()->get_failed_count(); diff --git a/src/tests/common/GOTestCollection.cpp b/src/tests/common/GOTestCollection.cpp index 465070aa2..0c2b9a173 100644 --- a/src/tests/common/GOTestCollection.cpp +++ b/src/tests/common/GOTestCollection.cpp @@ -13,11 +13,6 @@ GOTestCollection::GOTestCollection() {} -// GOTestCollection::~GOTestCollection() { -// // Destroy the initialized tests in vector -// tests_.clear(); -// } - void GOTestCollection::add_test(GOTest *test) { /* This method allows to add tests classes (derived from GOTest). diff --git a/src/tests/common/GOTestCollection.h b/src/tests/common/GOTestCollection.h index 94f042145..f04718a58 100644 --- a/src/tests/common/GOTestCollection.h +++ b/src/tests/common/GOTestCollection.h @@ -9,7 +9,6 @@ #include "GOTest.h" #include "GOTestResultCollection.h" #include -#include class GOTestCollection { /* diff --git a/src/tests/common/GOTestException.h b/src/tests/common/GOTestException.h index d1f28a3f3..8052e2557 100644 --- a/src/tests/common/GOTestException.h +++ b/src/tests/common/GOTestException.h @@ -8,16 +8,16 @@ #include #include #include -#include +#include class GOTestException : public std::exception { private: - wxString message; + std::string message; public: - GOTestException(wxString msg) : message(msg) {} - wxString what() { - wxString returned_message = message; + GOTestException(std::string msg) : message(msg) {} + std::string what() { + std::string returned_message = message; returned_message = returned_message + "\n"; return returned_message; diff --git a/src/tests/common/GOTestResult.cpp b/src/tests/common/GOTestResult.cpp index 05e90e59e..9fbb184d6 100644 --- a/src/tests/common/GOTestResult.cpp +++ b/src/tests/common/GOTestResult.cpp @@ -6,15 +6,19 @@ #include "GOTestResult.h" #include #include +#include #include -GOTestResult::GOTestResult() { this->failed = false; } +GOTestResult::GOTestResult() { + m_result_message = ""; + this->failed = false; +} -GOTestResult::GOTestResult(wxString message) : m_result_message(message) { +GOTestResult::GOTestResult(std::string message) : m_result_message(message) { failed = false; } -GOTestResult::GOTestResult(wxString message, bool failed) +GOTestResult::GOTestResult(std::string message, bool failed) : m_result_message(message) { failed = failed; } diff --git a/src/tests/common/GOTestResult.h b/src/tests/common/GOTestResult.h index 436b89405..1fdfc946d 100644 --- a/src/tests/common/GOTestResult.h +++ b/src/tests/common/GOTestResult.h @@ -12,24 +12,19 @@ #include "GOTest.h" #include -#include class GOTestResult { private: - wxString m_result_message; + std::string m_result_message; bool failed; public: GOTestResult(); - GOTestResult(wxString message); - GOTestResult(wxString message, bool failed); + GOTestResult(std::string message); + GOTestResult(std::string message, bool failed); - const wxString GetMessage() { - wxString result = ""; - result += m_result_message; - return result; - } + const std::string GetMessage() { return m_result_message; } bool isFailed() { return failed; } }; diff --git a/src/tests/common/GOTestUtils.h b/src/tests/common/GOTestUtils.h index f802c26c8..ea3fb8cca 100644 --- a/src/tests/common/GOTestUtils.h +++ b/src/tests/common/GOTestUtils.h @@ -12,7 +12,7 @@ class GOTestUtils { */ public: - void GOAssert(bool expression, wxString message) { + void GOAssert(bool expression, std::string message) { /** * This util function should be called as soon as we want to test an * expression in the test framework and launch the appropriate Exception diff --git a/src/tests/testing/model/GOTestOrganModel.cpp b/src/tests/testing/model/GOTestOrganModel.cpp index e0f5375db..131eaf5a8 100644 --- a/src/tests/testing/model/GOTestOrganModel.cpp +++ b/src/tests/testing/model/GOTestOrganModel.cpp @@ -17,7 +17,7 @@ GOTestOrganModel::~GOTestOrganModel() {} void GOTestOrganModel::run() { - wxString message; + std::string message; // Set OrganModel Modified this->controller->SetOrganModelModified(true); message = "Is Organ Modified value is not True"; diff --git a/src/tests/testing/model/GOTestSwitch.cpp b/src/tests/testing/model/GOTestSwitch.cpp index c81316286..cd3dfad3a 100644 --- a/src/tests/testing/model/GOTestSwitch.cpp +++ b/src/tests/testing/model/GOTestSwitch.cpp @@ -10,7 +10,7 @@ GOTestSwitch::~GOTestSwitch() {} void GOTestSwitch::run() { - wxString message; + std::string message; // Check global Switch GOSwitch *go_switch = new GOSwitch(*this->controller); diff --git a/src/tests/testing/model/GOTestWindchest.cpp b/src/tests/testing/model/GOTestWindchest.cpp index 6402d977a..c406d0b05 100644 --- a/src/tests/testing/model/GOTestWindchest.cpp +++ b/src/tests/testing/model/GOTestWindchest.cpp @@ -21,7 +21,7 @@ GOTestWindchest::~GOTestWindchest() {} void GOTestWindchest::run() { - wxString message; + std::string message; // Check the size of Windchest is correct unsigned w_size; w_size = this->controller->AddWindchest(new GOWindchest(*this->controller));