@@ -131,6 +131,10 @@ TEST_P(get_data_no_data_tests, no_data)
131
131
132
132
std::vector<StatisticsData> result;
133
133
134
+ // The number of bins is also used for the time interval so the time interval correspoding to each data point is
135
+ // exactly 1 second.
136
+ uint16_t bins = 10 ;
137
+
134
138
if (entity2.is_valid ())
135
139
{
136
140
result = StatisticsBackend::get_data (
@@ -148,12 +152,12 @@ TEST_P(get_data_no_data_tests, no_data)
148
152
data_type,
149
153
std::vector<EntityId>(1 , entity1),
150
154
std::vector<EntityId>(1 , entity2),
151
- 10 ,
155
+ bins ,
152
156
Timestamp (),
153
- Timestamp () + std::chrono::seconds (10 ),
157
+ Timestamp () + std::chrono::seconds (bins ),
154
158
statistic);
155
159
156
- ASSERT_EQ (10 , result.size ());
160
+ ASSERT_EQ (bins , result.size ());
157
161
}
158
162
else
159
163
{
@@ -170,18 +174,21 @@ TEST_P(get_data_no_data_tests, no_data)
170
174
result = StatisticsBackend::get_data (
171
175
data_type,
172
176
std::vector<EntityId>(1 , entity1),
173
- 10 ,
177
+ bins ,
174
178
Timestamp (),
175
- Timestamp () + std::chrono::seconds (10 ),
179
+ Timestamp () + std::chrono::seconds (bins ),
176
180
statistic);
177
181
178
- ASSERT_EQ (10 , result.size ());
182
+ ASSERT_EQ (bins , result.size ());
179
183
}
180
184
181
185
for (size_t i = 0 ; i < result.size (); ++i)
182
186
{
183
187
ASSERT_TRUE (std::isnan (result[i].second ));
184
- ASSERT_EQ (Timestamp () + std::chrono::seconds (i), result[i].first );
188
+ // The timestamp of each datapoint is the timestamp correspoding to the end of the time interval. For this
189
+ // tests the time interval is configure to be 1 second as the number of bins is equal to the time interval in
190
+ // seconds.
191
+ ASSERT_EQ (Timestamp () + std::chrono::seconds (1 ) + std::chrono::seconds (i), result[i].first );
185
192
}
186
193
}
187
194
@@ -481,7 +488,7 @@ void fill_expected_result (
481
488
for (uint16_t i = 0 ; i < nbins; ++i)
482
489
{
483
490
StatisticsData data;
484
- data.first = start + (bin_size * i);
491
+ data.first = start + bin_size + (bin_size * i);
485
492
data.second = count ? 0 : std::numeric_limits<double >::quiet_NaN ();
486
493
expected.push_back (data);
487
494
}
0 commit comments