@@ -33,13 +33,15 @@ struct CallCounter {
3333 std::atomic<Idx> setup_calls{};
3434 std::atomic<Idx> winddown_calls{};
3535 std::atomic<Idx> thread_safe_add_calculation_info_calls{};
36+ std::atomic<Idx> reset_calculation_info_calls{};
3637
3738 void reset_counters () {
3839 calculate_calls = 0 ;
3940 cache_calculate_calls = 0 ;
4041 setup_calls = 0 ;
4142 winddown_calls = 0 ;
4243 thread_safe_add_calculation_info_calls = 0 ;
44+ reset_calculation_info_calls = 0 ;
4345 }
4446};
4547
@@ -60,6 +62,7 @@ class JobAdapterMock : public JobInterface<JobAdapterMock> {
6062 Idx get_thread_safe_add_calculation_info_counter () const {
6163 return counter_->thread_safe_add_calculation_info_calls ;
6264 }
65+ Idx get_reset_calculation_info_counter () const { return counter_->reset_calculation_info_calls ; }
6366
6467 private:
6568 friend class JobInterface <JobAdapterMock>;
@@ -77,6 +80,7 @@ class JobAdapterMock : public JobInterface<JobAdapterMock> {
7780 void thread_safe_add_calculation_info_impl (CalculationInfo const & /* info*/ ) const {
7881 ++(counter_->thread_safe_add_calculation_info_calls );
7982 }
83+ void reset_calculation_info_impl () const { ++(counter_->reset_calculation_info_calls ); }
8084};
8185
8286class SomeTestException : public std ::runtime_error {
@@ -102,6 +106,8 @@ TEST_CASE("Test job dispatch logic") {
102106 CHECK (expected_result == actual_result);
103107 CHECK (adapter.get_calculate_counter () == 1 );
104108 CHECK (adapter.get_cache_calculate_counter () == 0 ); // no cache calculation in this case
109+ CHECK (adapter.get_reset_calculation_info_counter () ==
110+ adapter.get_calculate_counter () + adapter.get_cache_calculate_counter ());
105111 }
106112 SUBCASE (" No scenarios" ) {
107113 bool const has_data = true ;
@@ -113,6 +119,8 @@ TEST_CASE("Test job dispatch logic") {
113119 // no calculations should be done
114120 CHECK (adapter.get_calculate_counter () == 0 );
115121 CHECK (adapter.get_cache_calculate_counter () == 0 );
122+ CHECK (adapter.get_reset_calculation_info_counter () ==
123+ adapter.get_calculate_counter () + adapter.get_cache_calculate_counter ());
116124 }
117125 SUBCASE (" With scenarios and update data" ) {
118126 bool const has_data = true ;
@@ -125,6 +133,8 @@ TEST_CASE("Test job dispatch logic") {
125133 // n_scenarios calculations should be done as we run sequentially
126134 CHECK (adapter.get_calculate_counter () == n_scenarios);
127135 CHECK (adapter.get_cache_calculate_counter () == 1 ); // cache calculation is done
136+ CHECK (adapter.get_reset_calculation_info_counter () ==
137+ adapter.get_calculate_counter () + adapter.get_cache_calculate_counter ());
128138 }
129139 }
130140 SUBCASE (" Test single_thread_job" ) {
@@ -151,6 +161,8 @@ TEST_CASE("Test job dispatch logic") {
151161 CHECK (adapter_.get_winddown_counter () == expected_calls);
152162 CHECK (adapter_.get_calculate_counter () == expected_calls);
153163 CHECK (adapter_.get_thread_safe_add_calculation_info_counter () == 1 ); // always called once
164+ CHECK (adapter_.get_reset_calculation_info_counter () ==
165+ adapter_.get_calculate_counter () + adapter_.get_cache_calculate_counter ());
154166 };
155167
156168 adapter.prepare_job_dispatch (update_data); // replicate preparation step from batch_calculation
0 commit comments