@@ -33,13 +33,15 @@ struct CallCounter {
33
33
std::atomic<Idx> setup_calls{};
34
34
std::atomic<Idx> winddown_calls{};
35
35
std::atomic<Idx> thread_safe_add_calculation_info_calls{};
36
+ std::atomic<Idx> reset_calculation_info_calls{};
36
37
37
38
void reset_counters () {
38
39
calculate_calls = 0 ;
39
40
cache_calculate_calls = 0 ;
40
41
setup_calls = 0 ;
41
42
winddown_calls = 0 ;
42
43
thread_safe_add_calculation_info_calls = 0 ;
44
+ reset_calculation_info_calls = 0 ;
43
45
}
44
46
};
45
47
@@ -60,6 +62,7 @@ class JobAdapterMock : public JobInterface<JobAdapterMock> {
60
62
Idx get_thread_safe_add_calculation_info_counter () const {
61
63
return counter_->thread_safe_add_calculation_info_calls ;
62
64
}
65
+ Idx get_reset_calculation_info_counter () const { return counter_->reset_calculation_info_calls ; }
63
66
64
67
private:
65
68
friend class JobInterface <JobAdapterMock>;
@@ -77,6 +80,7 @@ class JobAdapterMock : public JobInterface<JobAdapterMock> {
77
80
void thread_safe_add_calculation_info_impl (CalculationInfo const & /* info*/ ) const {
78
81
++(counter_->thread_safe_add_calculation_info_calls );
79
82
}
83
+ void reset_calculation_info_impl () const { ++(counter_->reset_calculation_info_calls ); }
80
84
};
81
85
82
86
class SomeTestException : public std ::runtime_error {
@@ -102,6 +106,8 @@ TEST_CASE("Test job dispatch logic") {
102
106
CHECK (expected_result == actual_result);
103
107
CHECK (adapter.get_calculate_counter () == 1 );
104
108
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 ());
105
111
}
106
112
SUBCASE (" No scenarios" ) {
107
113
bool const has_data = true ;
@@ -113,6 +119,8 @@ TEST_CASE("Test job dispatch logic") {
113
119
// no calculations should be done
114
120
CHECK (adapter.get_calculate_counter () == 0 );
115
121
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 ());
116
124
}
117
125
SUBCASE (" With scenarios and update data" ) {
118
126
bool const has_data = true ;
@@ -125,6 +133,8 @@ TEST_CASE("Test job dispatch logic") {
125
133
// n_scenarios calculations should be done as we run sequentially
126
134
CHECK (adapter.get_calculate_counter () == n_scenarios);
127
135
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 ());
128
138
}
129
139
}
130
140
SUBCASE (" Test single_thread_job" ) {
@@ -151,6 +161,8 @@ TEST_CASE("Test job dispatch logic") {
151
161
CHECK (adapter_.get_winddown_counter () == expected_calls);
152
162
CHECK (adapter_.get_calculate_counter () == expected_calls);
153
163
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 ());
154
166
};
155
167
156
168
adapter.prepare_job_dispatch (update_data); // replicate preparation step from batch_calculation
0 commit comments