Skip to content

Commit fba723c

Browse files
committed
Rework
1 parent b5e1fbc commit fba723c

2 files changed

Lines changed: 17 additions & 4 deletions

File tree

modules/core/task/include/task.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ class Task {
6565
std::vector<std::string> right_functions_order_ = {"Validation", "PreProcessing", "Run", "PostProcessing"};
6666
static constexpr double kMaxTestTime = 1.0;
6767
std::chrono::high_resolution_clock::time_point tmp_time_point_;
68+
bool functions_order_validation_ = true;
6869
};
6970

7071
} // namespace ppc::core

modules/core/task/src/task.cpp

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,9 @@ void ppc::core::Task::InternalOrderTest(const std::string& str) {
4949

5050
for (size_t i = 0; i < functions_order_.size(); i++) {
5151
if (functions_order_[i] != right_functions_order_[i % right_functions_order_.size()]) {
52-
throw std::invalid_argument("ORDER OF FUCTIONS IS NOT RIGHT: \n" + std::string("Serial number: ") +
53-
std::to_string(i + 1) + "\n" + std::string("Yours function: ") + functions_order_[i] +
52+
functions_order_validation_ = false;
53+
throw std::invalid_argument("ORDER OF FUNCTIONS IS NOT RIGHT: \n" + std::string("Serial number: ") +
54+
std::to_string(i + 1) + "\n" + std::string("Your function: ") + functions_order_[i] +
5455
"\n" + std::string("Expected function: ") + right_functions_order_[i]);
5556
}
5657
}
@@ -76,9 +77,20 @@ void ppc::core::Task::InternalOrderTest(const std::string& str) {
7677
}
7778

7879
ppc::core::Task::~Task() {
79-
if (functions_order_ != right_functions_order_) {
80-
std::cerr << "ORDER OF FUNCTIONS IS NOT RIGHT: Task functions order is invalid\n";
80+
if (functions_order_.empty()) {
81+
std::cerr << "ORDER OF FUNCTIONS IS NOT RIGHT: No task functions were executed\n";
8182
std::terminate();
8283
}
84+
if (functions_order_validation_) {
85+
for (size_t i = 0; i < functions_order_.size(); i++) {
86+
if (functions_order_[i] != right_functions_order_[i % right_functions_order_.size()]) {
87+
std::cerr << "ORDER OF FUNCTIONS IS NOT RIGHT: \n"
88+
<< std::string("Serial number: ") << std::to_string(i + 1) << "\n"
89+
<< std::string("Your function: ") << functions_order_[i] << "\n"
90+
<< std::string("Expected function: ") << right_functions_order_[i] << "\n";
91+
std::terminate();
92+
}
93+
}
94+
}
8395
functions_order_.clear();
8496
}

0 commit comments

Comments
 (0)