Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions modules/core/task/include/task.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ class Task {
std::vector<std::string> right_functions_order_ = {"Validation", "PreProcessing", "Run", "PostProcessing"};
static constexpr double kMaxTestTime = 1.0;
std::chrono::high_resolution_clock::time_point tmp_time_point_;
bool functions_order_validation_ = true;
};

} // namespace ppc::core
25 changes: 22 additions & 3 deletions modules/core/task/src/task.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

#include <chrono>
#include <cstddef>
#include <exception>
#include <iomanip>
#include <iostream>
#include <sstream>
Expand Down Expand Up @@ -48,8 +49,9 @@ void ppc::core::Task::InternalOrderTest(const std::string& str) {

for (size_t i = 0; i < functions_order_.size(); i++) {
if (functions_order_[i] != right_functions_order_[i % right_functions_order_.size()]) {
throw std::invalid_argument("ORDER OF FUCTIONS IS NOT RIGHT: \n" + std::string("Serial number: ") +
std::to_string(i + 1) + "\n" + std::string("Yours function: ") + functions_order_[i] +
functions_order_validation_ = false;
throw std::invalid_argument("ORDER OF FUNCTIONS IS NOT RIGHT: \n" + std::string("Serial number: ") +
std::to_string(i + 1) + "\n" + std::string("Your function: ") + functions_order_[i] +
"\n" + std::string("Expected function: ") + right_functions_order_[i]);
}
}
Expand All @@ -74,4 +76,21 @@ void ppc::core::Task::InternalOrderTest(const std::string& str) {
}
}

ppc::core::Task::~Task() { functions_order_.clear(); }
ppc::core::Task::~Task() {
if (functions_order_.empty()) {
std::cerr << "ORDER OF FUNCTIONS IS NOT RIGHT: No task functions were executed\n";
std::terminate();
}
if (functions_order_validation_) {
for (size_t i = 0; i < functions_order_.size(); i++) {
if (functions_order_[i] != right_functions_order_[i % right_functions_order_.size()]) {
std::cerr << "ORDER OF FUNCTIONS IS NOT RIGHT: \n"
<< std::string("Serial number: ") << std::to_string(i + 1) << "\n"
<< std::string("Your function: ") << functions_order_[i] << "\n"
<< std::string("Expected function: ") << right_functions_order_[i] << "\n";
std::terminate();
}
}
}
functions_order_.clear();
}
Loading