22
33#include < chrono>
44#include < cstddef>
5+ #include < exception>
56#include < iomanip>
67#include < iostream>
78#include < sstream>
@@ -48,8 +49,9 @@ void ppc::core::Task::InternalOrderTest(const std::string& str) {
4849
4950 for (size_t i = 0 ; i < functions_order_.size (); i++) {
5051 if (functions_order_[i] != right_functions_order_[i % right_functions_order_.size ()]) {
51- throw std::invalid_argument (" ORDER OF FUCTIONS IS NOT RIGHT: \n " + std::string (" Serial number: " ) +
52- 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] +
5355 " \n " + std::string (" Expected function: " ) + right_functions_order_[i]);
5456 }
5557 }
@@ -74,4 +76,21 @@ void ppc::core::Task::InternalOrderTest(const std::string& str) {
7476 }
7577}
7678
77- ppc::core::Task::~Task () { functions_order_.clear (); }
79+ ppc::core::Task::~Task () {
80+ if (functions_order_.empty ()) {
81+ std::cerr << " ORDER OF FUNCTIONS IS NOT RIGHT: No task functions were executed\n " ;
82+ std::terminate ();
83+ }
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+ }
95+ functions_order_.clear ();
96+ }
0 commit comments