Skip to content

Commit 27da820

Browse files
committed
expand test
1 parent c438332 commit 27da820

File tree

1 file changed

+19
-3
lines changed

1 file changed

+19
-3
lines changed

cpp/tests/test_save_results.cpp

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -229,13 +229,14 @@ TEST(TestSaveResult, save_result_with_params)
229229

230230
TEST(TestSaveResult, save_result_order)
231231
{
232-
// case: check order of results, where lexical ordering would rearrange the results;
233-
// expect: order follows the ids
234232
std::vector<mio::TimeSeries<double>> results{
235233
mio::TimeSeries<double>(0, Eigen::VectorX<double>::Constant(1, 0)),
236234
mio::TimeSeries<double>(0, Eigen::VectorX<double>::Constant(1, 1)),
237235
mio::TimeSeries<double>(0, Eigen::VectorX<double>::Constant(1, 2))};
238-
std::vector<int> ids = {1, 2, 10};
236+
237+
// case: check order of results, where lexical ordering would rearrange the results;
238+
// expect: order follows the ids
239+
std::vector<int> ids = {1, 2, 10};
239240

240241
TempFileRegister file_register;
241242
auto results_file_path = file_register.get_unique_path("test_result-%%%%-%%%%.h5");
@@ -248,6 +249,21 @@ TEST(TestSaveResult, save_result_order)
248249
ASSERT_DOUBLE_EQ(results_from_file.value()[0].get_groups()[Eigen::Index(0)][Eigen::Index(0)], 0);
249250
ASSERT_DOUBLE_EQ(results_from_file.value()[1].get_groups()[Eigen::Index(0)][Eigen::Index(0)], 1);
250251
ASSERT_DOUBLE_EQ(results_from_file.value()[2].get_groups()[Eigen::Index(0)][Eigen::Index(0)], 2);
252+
253+
// case: check order of results;
254+
// expect: order is changed due to ids not increasing
255+
ids = {1, 10, 2};
256+
257+
results_file_path = file_register.get_unique_path("test_result-%%%%-%%%%.h5");
258+
save_result_status = mio::save_result(results, ids, 1, results_file_path);
259+
ASSERT_TRUE(save_result_status);
260+
261+
results_from_file = mio::read_result(results_file_path);
262+
ASSERT_TRUE(results_from_file);
263+
264+
ASSERT_DOUBLE_EQ(results_from_file.value()[0].get_groups()[Eigen::Index(0)][Eigen::Index(0)], 0);
265+
ASSERT_DOUBLE_EQ(results_from_file.value()[1].get_groups()[Eigen::Index(0)][Eigen::Index(0)], 2);
266+
ASSERT_DOUBLE_EQ(results_from_file.value()[2].get_groups()[Eigen::Index(0)][Eigen::Index(0)], 1);
251267
}
252268

253269
TEST(TestSaveResult, save_percentiles_and_sums)

0 commit comments

Comments
 (0)