From ff31f76260562f508e182c706f83daaee0c4ebb1 Mon Sep 17 00:00:00 2001 From: reneSchm <49305466+reneSchm@users.noreply.github.com> Date: Tue, 16 Dec 2025 16:38:33 +0100 Subject: [PATCH 1/4] set gtest flags brief and shuffle in debug builds. add LogLevelOverride to temporarily change log levels. make RandomNumberTest use the same seed as thread_local_rng instead getting a new one each test, but still reset the counter. only log rng seeds once. turn off several unneeded outputs. --- cpp/tests/random_number_test.h | 4 ++-- cpp/tests/test_abstract_parameter_dist.cpp | 11 --------- cpp/tests/test_analyze_result.cpp | 12 ++++++++-- cpp/tests/test_binary_serializer.cpp | 16 ++++--------- cpp/tests/test_epi_data_io.cpp | 13 +++++----- cpp/tests/test_graph.cpp | 8 ++++++- cpp/tests/test_odemseirs4.cpp | 3 +++ cpp/tests/test_odesecir.cpp | 28 ++++++++++------------ cpp/tests/test_odesecir_ageres.cpp | 4 ++-- cpp/tests/test_odesecirts.cpp | 13 +++------- cpp/tests/test_odesecirvvs.cpp | 4 ---- cpp/tests/test_odeseirv.cpp | 3 +++ cpp/tests/test_parameter_studies.cpp | 24 ++++++------------- cpp/tests/test_time_series.cpp | 2 ++ cpp/tests/test_uncertain.cpp | 4 ---- cpp/tests/test_utils.cpp | 27 +++++++++++++++++++++ cpp/tests/testmain.cpp | 12 +++++++++- cpp/tests/utils.h | 19 +++++++++++++++ 18 files changed, 121 insertions(+), 86 deletions(-) diff --git a/cpp/tests/random_number_test.h b/cpp/tests/random_number_test.h index 351956e3bc..fe70f738c1 100644 --- a/cpp/tests/random_number_test.h +++ b/cpp/tests/random_number_test.h @@ -59,9 +59,9 @@ class RandomNumberTest : public ::testing::Test protected: void SetUp() override { - log_rng_seeds(m_rng, mio::LogLevel::warn); + m_rng.set_counter(mio::Counter{0}); } private: - mio::RandomNumberGenerator m_rng{}; ///< Seeded rng used by this test fixture. + static inline mio::RandomNumberGenerator m_rng = mio::thread_local_rng(); ///< Seeded rng used by this test fixture. }; diff --git a/cpp/tests/test_abstract_parameter_dist.cpp b/cpp/tests/test_abstract_parameter_dist.cpp index a3c3320b31..8bd5efb30a 100644 --- a/cpp/tests/test_abstract_parameter_dist.cpp +++ b/cpp/tests/test_abstract_parameter_dist.cpp @@ -23,13 +23,10 @@ #include "memilio/utils/random_number_generator.h" #include "models/abm/personal_rng.h" #include -#include #include TEST(AbstractParameterDist, test_abstract_normal_distribution) { - mio::log_thread_local_rng_seeds(mio::LogLevel::warn); - mio::AbstractParameterDistribution p1(mio::ParameterDistributionNormal(10., 0.5)); mio::AbstractParameterDistribution p2(mio::ParameterDistributionNormal(20., 0.3)); auto params1 = std::vector{10., 0.5}; @@ -52,8 +49,6 @@ TEST(AbstractParameterDist, test_abstract_normal_distribution) TEST(AbstractParameterDist, test_abstract_uniform_distribution) { - mio::log_thread_local_rng_seeds(mio::LogLevel::warn); - mio::AbstractParameterDistribution p1(mio::ParameterDistributionUniform(0., 1.)); mio::AbstractParameterDistribution p2(mio::ParameterDistributionUniform(2., 3.)); auto params1 = std::vector{0., 1.}; @@ -78,8 +73,6 @@ TEST(AbstractParameterDist, test_abstract_uniform_distribution) TEST(AbstractParameterDist, test_abstract_lognormal_distribution) { - mio::log_thread_local_rng_seeds(mio::LogLevel::warn); - mio::AbstractParameterDistribution p1(mio::ParameterDistributionLogNormal(1., 0.25)); mio::AbstractParameterDistribution p2(mio::ParameterDistributionLogNormal(2., 0.1)); auto params1 = std::vector{1., 0.25}; @@ -102,8 +95,6 @@ TEST(AbstractParameterDist, test_abstract_lognormal_distribution) TEST(AbstractParameterDist, test_abstract_exponential_distribution) { - mio::log_thread_local_rng_seeds(mio::LogLevel::warn); - mio::AbstractParameterDistribution p1(mio::ParameterDistributionExponential(1.)); mio::AbstractParameterDistribution p2(mio::ParameterDistributionExponential(2.)); auto params1 = std::vector{1.}; @@ -126,8 +117,6 @@ TEST(AbstractParameterDist, test_abstract_exponential_distribution) TEST(AbstractParameterDist, test_abstract_constant_distribution) { - mio::log_thread_local_rng_seeds(mio::LogLevel::warn); - mio::AbstractParameterDistribution p1(mio::ParameterDistributionConstant(1.)); mio::AbstractParameterDistribution p2(mio::ParameterDistributionConstant(2.)); auto params1 = std::vector{1.}; diff --git a/cpp/tests/test_analyze_result.cpp b/cpp/tests/test_analyze_result.cpp index 5360c7c3de..6bb740cff0 100644 --- a/cpp/tests/test_analyze_result.cpp +++ b/cpp/tests/test_analyze_result.cpp @@ -26,6 +26,7 @@ #include "memilio/utils/time_series.h" #include "ode_secir/analyze_result.h" #include "ode_secir/model.h" +#include "utils.h" #include "gtest/gtest.h" #include "gmock/gmock.h" @@ -679,6 +680,9 @@ TEST(TestMergeTimeSeries, joint_tp_add) TEST(TestMergeTimeSeries, joint_tp) { + mio::RedirectLogger logger; + logger.capture(); + mio::TimeSeries ts1(2); mio::TimeSeries ts2(2); ts1.add_time_point(0., mio::TimeSeries::Vector::Constant(2, 1.)); @@ -686,8 +690,9 @@ TEST(TestMergeTimeSeries, joint_tp) //Check for both TimeSeries having only one time point auto merged_ts_status = mio::merge_time_series(ts1, ts2, false); - auto merged_ts = merged_ts_status.value(); + EXPECT_THAT(logger.read(), testing::HasSubstr("Both TimeSeries have values for t=0")); ASSERT_TRUE(merged_ts_status); + auto merged_ts = merged_ts_status.value(); ASSERT_EQ(merged_ts.get_num_time_points(), 1); EXPECT_NEAR(merged_ts.get_time(0), 0., 1e-12); EXPECT_NEAR(merged_ts.get_value(0)[0], 1., 1e-12); @@ -698,8 +703,10 @@ TEST(TestMergeTimeSeries, joint_tp) ts2.add_time_point(1., mio::TimeSeries::Vector::Constant(2, 3.)); merged_ts_status = mio::merge_time_series(ts1, ts2, false); - merged_ts = merged_ts_status.value(); + EXPECT_THAT(logger.read(), testing::AllOf(testing::HasSubstr("Both TimeSeries have values for t=0"), + testing::HasSubstr("Both TimeSeries have values for t=1"))); ASSERT_TRUE(merged_ts_status); + merged_ts = merged_ts_status.value(); ASSERT_EQ(merged_ts.get_num_time_points(), 2); EXPECT_NEAR(merged_ts.get_time(0), 0., 1e-12); EXPECT_NEAR(merged_ts.get_value(0)[0], 1., 1e-12); @@ -707,4 +714,5 @@ TEST(TestMergeTimeSeries, joint_tp) EXPECT_NEAR(merged_ts.get_time(1), 1., 1e-12); EXPECT_NEAR(merged_ts.get_value(1)[0], 2., 1e-12); EXPECT_NEAR(merged_ts.get_value(1)[1], 2., 1e-12); + logger.release(); } diff --git a/cpp/tests/test_binary_serializer.cpp b/cpp/tests/test_binary_serializer.cpp index 893d746a2f..8e4a7c5876 100644 --- a/cpp/tests/test_binary_serializer.cpp +++ b/cpp/tests/test_binary_serializer.cpp @@ -17,22 +17,17 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#include "boost/none.hpp" -#include "boost/none_t.hpp" #include "matchers.h" -#include "memilio/epidemiology/damping.h" -#include "memilio/epidemiology/damping_sampling.h" #include "memilio/io/binary_serializer.h" #include "memilio/io/io.h" #include "memilio/utils/logging.h" -#include "memilio/utils/parameter_distributions.h" #include "memilio/utils/time_series.h" -#include "memilio/utils/uncertain_value.h" #include "ode_secir/model.h" #include "ode_secir/parameter_space.h" -#include "ode_secir/parameters.h" +#include "utils.h" + +#include "boost/none.hpp" #include "gtest/gtest.h" -#include namespace { @@ -180,10 +175,9 @@ TEST(BinarySerializer, model) //this test is only to make sure the correct number of bytes are serialized/deserialized //in a very complex object. correct serializing of single values is tested by other tests. mio::osecir::Model model{5}; - mio::set_log_level(mio::LogLevel::err); mio::osecir::set_params_distributions_normal(model, 0, 10, 0.01); - mio::set_log_level(mio::LogLevel::warn); auto stream = mio::serialize_binary(model); + mio::LogLevelOverride llo(mio::LogLevel::off); // suppress warnings from model constructor auto result = mio::deserialize_binary(stream, mio::Tag>{}); EXPECT_THAT(result, IsSuccess()); } @@ -233,4 +227,4 @@ TEST(ByteStream, reset) auto p = (unsigned char*)&i; EXPECT_TRUE(stream.read(p, sizeof(i))); EXPECT_EQ(i, 0); -} \ No newline at end of file +} diff --git a/cpp/tests/test_epi_data_io.cpp b/cpp/tests/test_epi_data_io.cpp index f29467e775..fca025d108 100644 --- a/cpp/tests/test_epi_data_io.cpp +++ b/cpp/tests/test_epi_data_io.cpp @@ -17,14 +17,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - -#include "abm/infection_state.h" #include "memilio/epidemiology/age_group.h" #include "memilio/geography/regions.h" #include "memilio/io/epi_data.h" #include "matchers.h" #include "memilio/io/io.h" -#include "memilio/io/mobility_io.h" #include "test_data_dir.h" #include "gtest/gtest.h" #include "json/value.h" @@ -32,6 +29,7 @@ #include "ode_secirts/parameters_io.h" #include "memilio/utils/stl_util.h" #include "boost/optional/optional_io.hpp" +#include "utils.h" #include TEST(TestEpiDataIo, read_rki) @@ -423,9 +421,12 @@ TEST(TestEpiData, set_vaccination_data) model.parameters.set>(1); std::vector> model_vector{model}; - auto f = mio::osecirts::details::set_vaccination_data(model_vector, - mio::path_join(TEST_DATA_DIR, "vaccination_test.json"), - mio::Date(2022, 4, 15), county_ids, num_days); + { + mio::LogLevelOverride llo(mio::LogLevel::off); // suppress "Vaccination data only available from [...]" + mio::unused(mio::osecirts::details::set_vaccination_data(model_vector, + mio::path_join(TEST_DATA_DIR, "vaccination_test.json"), + mio::Date(2022, 4, 15), county_ids, num_days)); + } auto expected_values_PI = (Eigen::ArrayXd(num_age_groups * (num_days + 1)) << 7, 10, 20, 15, 10, 5, 2, 15, 8, 0).finished(); diff --git a/cpp/tests/test_graph.cpp b/cpp/tests/test_graph.cpp index bfffc6c8c2..7232ad0949 100644 --- a/cpp/tests/test_graph.cpp +++ b/cpp/tests/test_graph.cpp @@ -35,10 +35,12 @@ #include "matchers.h" #include "temp_file_register.h" #include "memilio/utils/stl_util.h" +#include "utils.h" #include "gmock/gmock-matchers.h" #include #include #include +#include #include #include @@ -148,7 +150,7 @@ TEST(TestGraph, graph_without_edges) std::vector ids = {1, 2}; mio::Graph g(ids, models); - + EXPECT_EQ(g.edges().size(), 0); EXPECT_EQ(g.nodes().size(), 2); EXPECT_EQ(g.nodes()[0].id, 1); @@ -373,7 +375,11 @@ TEST(TestGraphBuilder, Build_unique) builder.add_edge(1, 2, 200); builder.add_edge(2, 1, 300); + mio::RedirectLogger logger; + logger.capture(); auto g = std::move(builder).build(true); + EXPECT_THAT(logger.read(), testing::EndsWith("[warning] Removed duplicate edge(s)\n")); + logger.release(); EXPECT_EQ(g.nodes().size(), 3); EXPECT_EQ(g.edges().size(), 3); diff --git a/cpp/tests/test_odemseirs4.cpp b/cpp/tests/test_odemseirs4.cpp index c16eae4a18..49838adc85 100644 --- a/cpp/tests/test_odemseirs4.cpp +++ b/cpp/tests/test_odemseirs4.cpp @@ -23,6 +23,7 @@ #include "ode_mseirs4/model.h" #include "ode_mseirs4/infection_state.h" #include "ode_mseirs4/parameters.h" +#include "utils.h" #include @@ -113,6 +114,7 @@ TEST_F(ModelTestOdeMseirs4, checkPopulationConservation) TEST(TestOdeMseirs4, apply_constraints_parameters) { + mio::LogLevelOverride llo(mio::LogLevel::off); // hide contstraint warnings/errors mio::omseirs4::Model model; auto& params = model.parameters; @@ -148,6 +150,7 @@ TEST(TestOdeMseirs4, apply_constraints_parameters) TEST(TestOdeMseirs4, check_constraints_parameters) { + mio::LogLevelOverride llo(mio::LogLevel::off); // hide contstraint warnings/errors mio::omseirs4::Model model; auto& params = model.parameters; diff --git a/cpp/tests/test_odesecir.cpp b/cpp/tests/test_odesecir.cpp index 24533cc68d..89eee71060 100755 --- a/cpp/tests/test_odesecir.cpp +++ b/cpp/tests/test_odesecir.cpp @@ -30,6 +30,7 @@ #include "memilio/data/analyze_result.h" #include "memilio/math/adapt_rk.h" #include "memilio/geography/regions.h" +#include "utils.h" #include @@ -43,7 +44,7 @@ TEST(TestOdeSecir, compareWithPreviousRun) */ double t0 = 0; double tmax = 50; - double dt = 0.1; + double dt = 0.3; double cont_freq = 10; @@ -674,8 +675,8 @@ TEST(TestOdeSecir, testDamping) TEST(TestOdeSecir, testModelConstraints) { - mio::set_log_level( - mio::LogLevel::err); //as many random things are drawn, warnings are inevitable and cluster output + // as many random things are drawn, warnings are inevitable and cluster output + mio::LogLevelOverride llo(mio::LogLevel::err); double t0 = 0; double tmax = 57; // after 57 days with cont_freq 10 and winter, the virus would already decline double dt = 0.1; @@ -762,7 +763,6 @@ TEST(TestOdeSecir, testModelConstraints) EXPECT_LE(secihurd.get_value(i)[5], 9000) << " at row " << i; } } - mio::set_log_level(mio::LogLevel::warn); } TEST(TestOdeSecir, testAndTraceCapacity) @@ -1072,10 +1072,11 @@ TEST(TestOdeSecir, test_commuters) TEST(TestOdeSecir, check_constraints_parameters) { + mio::LogLevelOverride llo(mio::LogLevel::off); + auto model = mio::osecir::Model(1); EXPECT_EQ(model.parameters.check_constraints(), 0); - mio::set_log_level(mio::LogLevel::off); model.parameters.set>(-0.5); EXPECT_EQ(model.parameters.check_constraints(), 1); @@ -1145,18 +1146,18 @@ TEST(TestOdeSecir, check_constraints_parameters) model.parameters.set>(3); EXPECT_EQ(model.parameters.check_constraints(), 0); - mio::set_log_level(mio::LogLevel::warn); } TEST(TestOdeSecir, apply_constraints_parameters) { + mio::LogLevelOverride llo(mio::LogLevel::off); + auto model = mio::osecir::Model(1); auto indx_agegroup = mio::AgeGroup(0); const double tol_times = 1e-1; EXPECT_EQ(model.parameters.apply_constraints(), 0); - mio::set_log_level(mio::LogLevel::off); model.parameters.set>(-0.5); EXPECT_EQ(model.parameters.apply_constraints(), 1); EXPECT_EQ(model.parameters.get>(), 0); @@ -1227,7 +1228,6 @@ TEST(TestOdeSecir, apply_constraints_parameters) EXPECT_EQ(model.parameters.get>(), 0); EXPECT_EQ(model.parameters.apply_constraints(), 0); - mio::set_log_level(mio::LogLevel::warn); } #if defined(MEMILIO_HAS_JSONCPP) @@ -1343,7 +1343,8 @@ TEST_F(ModelTestOdeSecir, export_time_series_init) // Test the output of the function for a day way in the past. The model should be initialized with the population data since no Case data is available there. TEST_F(ModelTestOdeSecir, export_time_series_init_old_date) { - mio::set_log_level(mio::LogLevel::off); + mio::LogLevelOverride llo(mio::LogLevel::off); + TempFileRegister temp_file_register; auto tmp_results_dir = temp_file_register.get_unique_path(); EXPECT_THAT(mio::create_directory(tmp_results_dir), IsSuccess()); @@ -1375,7 +1376,6 @@ TEST_F(ModelTestOdeSecir, export_time_series_init_old_date) // sum of all compartments should be equal to the population EXPECT_NEAR(results_extrapolated.sum(), std::accumulate(population_data[0].begin(), population_data[0].end(), 0.0), 1e-8); - mio::set_log_level(mio::LogLevel::warn); } // // Model initialization should return same start values as export time series on that day @@ -1407,7 +1407,7 @@ TEST_F(ModelTestOdeSecir, model_initialization) // Calling the model initialization with a date way in the past should only initialize the model with the population data. TEST_F(ModelTestOdeSecir, model_initialization_old_date) { - mio::set_log_level(mio::LogLevel::off); + mio::LogLevelOverride llo(mio::LogLevel::off); // Vector assignment necessary as read_input_data_county changes model auto model_vector = std::vector>{model}; const auto pydata_dir_Germany = mio::path_join(TEST_DATA_DIR, "Germany", "pydata"); @@ -1438,12 +1438,12 @@ TEST_F(ModelTestOdeSecir, model_initialization_old_date) } // sum of all compartments should be equal to the population EXPECT_EQ(results_extrapolated.sum(), std::accumulate(population_data[0].begin(), population_data[0].end(), 0.0)); - mio::set_log_level(mio::LogLevel::warn); } TEST(TestOdeSecir, set_divi_data_invalid_dates) { - mio::set_log_level(mio::LogLevel::off); + mio::LogLevelOverride llo(mio::LogLevel::off); + auto model = mio::osecir::Model(1); model.populations.array().setConstant(1); auto model_vector = std::vector>{model}; @@ -1453,8 +1453,6 @@ TEST(TestOdeSecir, set_divi_data_invalid_dates) // Assure that populations is the same as before. EXPECT_THAT(print_wrap(model_vector[0].populations.array().cast()), MatrixNear(print_wrap(model.populations.array().cast()), 1e-10, 1e-10)); - - mio::set_log_level(mio::LogLevel::warn); } TEST(TestOdeSecir, set_divi_data_empty_data) diff --git a/cpp/tests/test_odesecir_ageres.cpp b/cpp/tests/test_odesecir_ageres.cpp index 4d8d4f0846..cb0066063e 100755 --- a/cpp/tests/test_odesecir_ageres.cpp +++ b/cpp/tests/test_odesecir_ageres.cpp @@ -32,7 +32,7 @@ TEST(TestOdeSecir, compareAgeResWithPreviousRun) */ double t0 = 0; double tmax = 50; - double dt = 0.1; + double dt = 0.3; double cont_freq = 10; @@ -111,7 +111,7 @@ TEST(TestOdeSecir, compareAgeResWithPreviousRunCashKarp) { double t0 = 0; double tmax = 50; - double dt = 0.1; + double dt = 0.3; double cont_freq = 10; diff --git a/cpp/tests/test_odesecirts.cpp b/cpp/tests/test_odesecirts.cpp index 4bf0d0e1a8..c14f1c15a5 100755 --- a/cpp/tests/test_odesecirts.cpp +++ b/cpp/tests/test_odesecirts.cpp @@ -35,7 +35,6 @@ #include "memilio/utils/custom_index_array.h" #include "memilio/utils/parameter_distributions.h" #include "memilio/utils/parameter_set.h" -#include "memilio/utils/random_number_generator.h" #include "memilio/utils/uncertain_value.h" #include "ode_secirts/infection_state.h" #include "ode_secirts/model.h" @@ -48,7 +47,6 @@ #include "gmock/gmock-matchers.h" #include #include -#include const mio::osecirts::Model& osecirts_testing_model() { @@ -141,7 +139,7 @@ TEST(TestOdeSECIRTS, get_flows) TEST(TestOdeSECIRTS, Simulation) { - auto sim = mio::osecirts::Simulation(osecirts_testing_model(), 0, 1); + auto sim = mio::osecirts::Simulation(osecirts_testing_model(), 0, 1); sim.set_integrator_core(std::make_unique>()); sim.advance(1); @@ -258,7 +256,8 @@ TEST(TestOdeSECIRTS, overflow_vaccinations) } // simulate one step with explicit Euler - auto result = mio::simulate_flows>(t0, tmax, dt, model, std::make_unique>()); + auto result = mio::simulate_flows>( + t0, tmax, dt, model, std::make_unique>()); // get the flow indices for each type of vaccination and also the indices of the susceptible compartments auto flow_indx_partial_vaccination = @@ -602,8 +601,6 @@ mio::osecirts::Model make_model(int num_age_groups, bool set_invalid_ini TEST(TestOdeSECIRTS, draw_sample_graph) { - mio::log_thread_local_rng_seeds(mio::LogLevel::warn); - mio::Graph, mio::MobilityParameters> graph; auto num_age_groups = 6; @@ -663,8 +660,6 @@ TEST(TestOdeSECIRTS, draw_sample_graph) TEST(TestOdeSECIRTS, draw_sample_model) { - mio::log_thread_local_rng_seeds(mio::LogLevel::warn); - auto num_age_groups = 6; auto model = make_model(num_age_groups, /*set_invalid_initial_value*/ true); mio::osecirts::draw_sample(model); @@ -1159,8 +1154,6 @@ TEST(TestOdeSECIRTS, set_vaccination_data_min_date_not_avail) TEST(TestOdeSECIRTS, parameter_percentiles) { - mio::log_thread_local_rng_seeds(mio::LogLevel::warn); - //build small graph auto model = make_model(5); auto graph = mio::Graph, mio::MobilityParameters>(); diff --git a/cpp/tests/test_odesecirvvs.cpp b/cpp/tests/test_odesecirvvs.cpp index 666e9132fb..13dbc43179 100755 --- a/cpp/tests/test_odesecirvvs.cpp +++ b/cpp/tests/test_odesecirvvs.cpp @@ -429,8 +429,6 @@ mio::osecirvvs::Model make_model(int num_age_groups, bool set_invalid_in TEST(TestOdeSECIRVVS, draw_sample) { - mio::log_thread_local_rng_seeds(mio::LogLevel::warn); - mio::Graph, mio::MobilityParameters> graph; auto num_age_groups = 6; @@ -1169,8 +1167,6 @@ TEST(TestOdeSECIRVVS, set_vaccination_data_min_date_not_avail) TEST(TestOdeSECIRVVS, parameter_percentiles) { - mio::log_thread_local_rng_seeds(mio::LogLevel::warn); - //build small graph auto model = make_model(5); auto graph = mio::Graph, mio::MobilityParameters>(); diff --git a/cpp/tests/test_odeseirv.cpp b/cpp/tests/test_odeseirv.cpp index 10e204da3b..c3ed1400d5 100644 --- a/cpp/tests/test_odeseirv.cpp +++ b/cpp/tests/test_odeseirv.cpp @@ -28,6 +28,7 @@ #include "ode_seirv/model.h" #include "ode_seirv/infection_state.h" #include "ode_seirv/parameters.h" +#include "utils.h" #include @@ -86,6 +87,7 @@ TEST(TestOdeSeirv, populationConservation) TEST(TestOdeSeirv, applyConstraints) { + mio::LogLevelOverride llo(mio::LogLevel::off); // hide contstraint warnings/errors mio::oseirv::Model model(1); // First: defaults should need no correction EXPECT_FALSE(model.parameters.apply_constraints()); @@ -105,6 +107,7 @@ TEST(TestOdeSeirv, applyConstraints) TEST(TestOdeSeirv, checkConstraints) { + mio::LogLevelOverride llo(mio::LogLevel::off); // hide contstraint warnings/errors mio::oseirv::Model model(1); EXPECT_FALSE(model.parameters.check_constraints()); diff --git a/cpp/tests/test_parameter_studies.cpp b/cpp/tests/test_parameter_studies.cpp index 91e51f738e..71bfdaae42 100644 --- a/cpp/tests/test_parameter_studies.cpp +++ b/cpp/tests/test_parameter_studies.cpp @@ -18,13 +18,13 @@ * limitations under the License. */ #include "memilio/config.h" -#include "memilio/utils/miompi.h" #include "memilio/utils/parameter_distributions.h" #include "ode_secir/model.h" #include "ode_secir/parameter_space.h" #include "memilio/compartments/parameter_studies.h" #include "memilio/mobility/metapopulation_mobility_instant.h" #include "memilio/utils/random_number_generator.h" +#include "utils.h" #include #include #include @@ -32,8 +32,6 @@ TEST(ParameterStudies, sample_from_secir_params) { - mio::log_thread_local_rng_seeds(mio::LogLevel::warn); - double t0 = 0; double tmax = 100; @@ -84,7 +82,10 @@ TEST(ParameterStudies, sample_from_secir_params) mio::osecir::set_params_distributions_normal(model, t0, tmax, 0.2); - draw_sample(model); + { + mio::LogLevelOverride llo(mio::LogLevel::off); // suppress draw sample warnings + draw_sample(model); + } for (auto i = mio::AgeGroup(0); i < params.get_num_groups(); i++) { ASSERT_EQ(params.get>()[mio::AgeGroup(0)].value(), @@ -162,8 +163,9 @@ TEST(ParameterStudies, sample_graph) graph.add_edge(0, 1, mio::MobilityParameters(Eigen::VectorXd::Constant(Eigen::Index(num_groups * 8), 1.0))); mio::ParameterStudy study(graph, 0.0, 0.0, 0.5, 1); - mio::log_rng_seeds(study.get_rng(), mio::LogLevel::warn); + auto ensemble_results = study.run_serial([](auto&& g, auto t0_, auto dt_, auto) { + mio::LogLevelOverride llo(mio::LogLevel::off); // suppress draw sample warnings auto copy = g; return mio::make_sampled_graph_simulation>(draw_sample(copy), t0_, dt_, dt_); @@ -183,8 +185,6 @@ TEST(ParameterStudies, sample_graph) TEST(ParameterStudies, test_normal_distribution) { - mio::log_thread_local_rng_seeds(mio::LogLevel::warn); - mio::ParameterDistributionNormal parameter_dist_normal_1; // check if standard deviation is reduced if between too narrow interval [min,max] has to be sampled. @@ -231,8 +231,6 @@ TEST(ParameterStudies, test_normal_distribution) TEST(ParameterStudies, test_uniform_distribution) { - mio::log_thread_local_rng_seeds(mio::LogLevel::warn); - // check if full argument constructor works correctly mio::ParameterDistributionUniform parameter_dist_unif(1.0, 10.0); @@ -249,8 +247,6 @@ TEST(ParameterStudies, test_uniform_distribution) TEST(ParameterStudies, test_lognormal_distribution) { - mio::log_thread_local_rng_seeds(mio::LogLevel::warn); - // check if full argument constructor works correctly mio::ParameterDistributionLogNormal parameter_dist_lognorm(0.0, 0.25); @@ -260,8 +256,6 @@ TEST(ParameterStudies, test_lognormal_distribution) TEST(ParameterStudies, test_exponential_distribution) { - mio::log_thread_local_rng_seeds(mio::LogLevel::warn); - // check if full argument constructor works correctly mio::ParameterDistributionExponential parameter_dist_exponential(1.); @@ -270,8 +264,6 @@ TEST(ParameterStudies, test_exponential_distribution) TEST(ParameterStudies, test_constant_distribution) { - mio::log_thread_local_rng_seeds(mio::LogLevel::warn); - // check if full argument constructor works correctly mio::ParameterDistributionConstant parameter_dist_constant(2.); @@ -326,8 +318,6 @@ TEST(ParameterStudies, test_predefined_samples) TEST(ParameterStudies, check_ensemble_run_result) { - mio::log_thread_local_rng_seeds(mio::LogLevel::warn); - double t0 = 0; double tmax = 50; diff --git a/cpp/tests/test_time_series.cpp b/cpp/tests/test_time_series.cpp index 88563c0fcd..e8057ed881 100644 --- a/cpp/tests/test_time_series.cpp +++ b/cpp/tests/test_time_series.cpp @@ -362,7 +362,9 @@ TYPED_TEST(TestTimeSeries, print_table_cout_overload) // Just test that the print_table overload without ostream argument doesn't throw any exceptions. // The function behaviour is tested in "TestTimeSeries.print_table". mio::TimeSeries ts = mio::TimeSeries::zero(1, 1); + std::cout.setstate(std::ios_base::failbit); ASSERT_NO_FATAL_FAILURE(ts.print_table()); + std::cout.clear(); } TYPED_TEST(TestTimeSeries, export_csv) diff --git a/cpp/tests/test_uncertain.cpp b/cpp/tests/test_uncertain.cpp index 2157fd11c0..3ba14b0cc6 100644 --- a/cpp/tests/test_uncertain.cpp +++ b/cpp/tests/test_uncertain.cpp @@ -95,8 +95,6 @@ TEST(TestUncertain, uncertain_value_assign) TEST(TestUncertain, uncertain_value_predef) { - mio::log_thread_local_rng_seeds(mio::LogLevel::warn); - mio::UncertainValue val(3.0); double dev_rel = 0.2; double lower_bound = std::max(1e-6, (1 - dev_rel * 2.6) * val); @@ -117,8 +115,6 @@ TEST(TestUncertain, uncertain_value_predef) TEST(TestUncertain, uncertain_matrix) { - mio::log_thread_local_rng_seeds(mio::LogLevel::warn); - mio::ContactMatrix contact_matrix(Eigen::MatrixXd::NullaryExpr(2, 2, [](auto i, auto j) -> double { return (i + 1) * (j + 1); })); diff --git a/cpp/tests/test_utils.cpp b/cpp/tests/test_utils.cpp index f5283a81b8..fee45638ab 100644 --- a/cpp/tests/test_utils.cpp +++ b/cpp/tests/test_utils.cpp @@ -164,6 +164,33 @@ TEST(TestUtils, RedirectLogger) logger.release(); } +TEST(TestUtils, LogLevelOverride) +{ + // test that LogLevelOverride behaves as intended + mio::RedirectLogger logger; + logger.capture(); + // sanity check that the capture works (ignoring the time stamp at the start) + mio::log_warning("Test0"); + EXPECT_THAT(logger.read(), testing::EndsWith("[redirect] [warning] Test0\n")); + // case: override to higher level, log at normal level; expect a usually emitted log to be ignored + { + mio::LogLevelOverride llo(mio::LogLevel::critical); + mio::log_warning("Test1"); + } + EXPECT_TRUE(logger.read().empty()); + // case: log at normal level, after higher level override; expect normal logging + mio::log_warning("Test2"); + EXPECT_THAT(logger.read(), testing::EndsWith("[redirect] [warning] Test2\n")); + // case: override to lower level, log at a level below normal; expect a usually ignored log to be emitted + { + mio::LogLevelOverride llo(mio::LogLevel::info); + mio::log_info("Test3"); + } + EXPECT_THAT(logger.read(), testing::EndsWith("[redirect] [info] Test3\n")); + + logger.release(); +} + TEST(TestUtils, base_dir) { auto base_dir = boost::filesystem::path(mio::base_dir()); diff --git a/cpp/tests/testmain.cpp b/cpp/tests/testmain.cpp index d2c17044a9..a68945ba59 100644 --- a/cpp/tests/testmain.cpp +++ b/cpp/tests/testmain.cpp @@ -25,9 +25,19 @@ int main(int argc, char** argv) { mio::mpi::init(); - mio::set_log_level(mio::LogLevel::warn); + mio::set_log_level(mio::LogLevel::info); // only used for logging testing environment info + mio::log_thread_local_rng_seeds(mio::LogLevel::info); +#ifndef NDEBUG + // in debug builds: + // suppress output from successful tests, so output from failures is easy to find + GTEST_FLAG_SET(brief, true); + // shuffle order of tests, to make sure they are not interdependant + GTEST_FLAG_SET(shuffle, true); +#endif ::testing::InitGoogleTest(&argc, argv); + + mio::set_log_level(mio::LogLevel::warn); // main log level for testing int retval = RUN_ALL_TESTS(); mio::mpi::finalize(); return retval; diff --git a/cpp/tests/utils.h b/cpp/tests/utils.h index bdbd52c0b7..73a993812e 100644 --- a/cpp/tests/utils.h +++ b/cpp/tests/utils.h @@ -31,6 +31,25 @@ namespace mio { +/// @brief Sets the default log level on creation, and resets it to the previous level on destruction. +class LogLevelOverride +{ +public: + LogLevelOverride(LogLevel temporary_level) + : m_previous_level(spdlog::default_logger()->level()) + { + set_log_level(temporary_level); + } + + ~LogLevelOverride() + { + spdlog::set_level(m_previous_level); + } + +private: + spdlog::level::level_enum m_previous_level; +}; + /// @brief Can be used to redirect an spdlog::logger. This may cause unintended side effects, like silencing errors! class RedirectLogger { From 9cd42419ce29d533b7eb076c41fd45e415d80752 Mon Sep 17 00:00:00 2001 From: reneSchm <49305466+reneSchm@users.noreply.github.com> Date: Thu, 18 Dec 2025 19:42:50 +0100 Subject: [PATCH 2/4] disable more outputs --- cpp/memilio/utils/parameter_distributions.h | 9 +-------- cpp/tests/test_odesecirts.cpp | 16 ++++++++++------ cpp/tests/test_odesecirvvs.cpp | 2 ++ cpp/tests/test_parameter_studies.cpp | 13 ++++++++++--- cpp/tests/test_save_results.cpp | 14 +++++++------- 5 files changed, 30 insertions(+), 24 deletions(-) diff --git a/cpp/memilio/utils/parameter_distributions.h b/cpp/memilio/utils/parameter_distributions.h index a84f885ea5..4990176121 100644 --- a/cpp/memilio/utils/parameter_distributions.h +++ b/cpp/memilio/utils/parameter_distributions.h @@ -20,7 +20,6 @@ #ifndef PARAMETER_DISTRIBUTIONS_H #define PARAMETER_DISTRIBUTIONS_H -#include "memilio/utils/compiler_diagnostics.h" #include "memilio/utils/logging.h" #include "memilio/utils/visitor.h" #include "memilio/utils/random_number_generator.h" @@ -275,11 +274,6 @@ class ParameterDistributionNormal : public VisitableParameterDistribution m_upper_bound || rnumb < m_lower_bound) && i < retries) { rnumb = m_distribution.get_distribution_instance()(rng, m_distribution.params); i++; @@ -430,7 +424,6 @@ class ParameterDistributionNormal : public VisitableParameterDistribution::min(); ScalarType m_quantile = 2.5758; // default is 0.995 quartile NormalDistribution::ParamType m_distribution; - bool m_log_stddev_change = true; }; template diff --git a/cpp/tests/test_odesecirts.cpp b/cpp/tests/test_odesecirts.cpp index c14f1c15a5..97aeddd430 100755 --- a/cpp/tests/test_odesecirts.cpp +++ b/cpp/tests/test_odesecirts.cpp @@ -19,6 +19,7 @@ */ #include "matchers.h" +#include "memilio/utils/logging.h" #include "temp_file_register.h" #include "test_data_dir.h" #include "memilio/data/analyze_result.h" @@ -42,6 +43,7 @@ #include "ode_secirts/parameters.h" #include "ode_secirts/parameters_io.h" #include "ode_secirts/analyze_result.h" +#include "utils.h" #include "gtest/gtest.h" #include "gmock/gmock-matchers.h" @@ -594,6 +596,7 @@ mio::osecirts::Model make_model(int num_age_groups, bool set_invalid_ini set_synthetic_population_data(model.populations, set_invalid_initial_value); set_demographic_parameters(model.parameters, set_invalid_initial_value); set_contact_parameters(model.parameters, set_invalid_initial_value); + mio::LogLevelOverride llo(mio::LogLevel::off); model.parameters.apply_constraints(); return model; } @@ -1037,12 +1040,13 @@ TEST(TestOdeSECIRTS, model_initialization) const std::vector> immunity_population = {{0.04, 0.04, 0.075, 0.08, 0.035, 0.01}, {0.61, 0.61, 0.62, 0.62, 0.58, 0.41}, {0.35, 0.35, 0.305, 0.3, 0.385, 0.58}}; - - ASSERT_THAT(mio::osecirts::read_input_data_county(model_vector, {2020, 12, 01}, {0}, - std::vector(size_t(num_age_groups), 1.0), 1.0, - TEST_DATA_DIR, 2, immunity_population, false), - IsSuccess()); - + { + mio::LogLevelOverride llo(mio::LogLevel::off); + ASSERT_THAT(mio::osecirts::read_input_data_county(model_vector, {2020, 12, 01}, {0}, + std::vector(size_t(num_age_groups), 1.0), 1.0, + TEST_DATA_DIR, 2, immunity_population, false), + IsSuccess()); + } // Values from data/export_time_series_init_osecirts.h5, for reading in comparison // operator for return of mio::read_result and model population needed. auto expected_values = diff --git a/cpp/tests/test_odesecirvvs.cpp b/cpp/tests/test_odesecirvvs.cpp index 13dbc43179..bf16230d9b 100755 --- a/cpp/tests/test_odesecirvvs.cpp +++ b/cpp/tests/test_odesecirvvs.cpp @@ -44,6 +44,7 @@ #include "ode_secirvvs/parameters.h" #include "ode_secirvvs/parameters_io.h" #include "ode_secirvvs/analyze_result.h" +#include "utils.h" #include "gtest/gtest.h" #include "gmock/gmock.h" @@ -423,6 +424,7 @@ mio::osecirvvs::Model make_model(int num_age_groups, bool set_invalid_in set_synthetic_population_data(model.populations, set_invalid_initial_value); set_demographic_parameters(model.parameters, set_invalid_initial_value); set_contact_parameters(model.parameters, set_invalid_initial_value); + mio::LogLevelOverride llo(mio::LogLevel::off); model.parameters.apply_constraints(); return model; } diff --git a/cpp/tests/test_parameter_studies.cpp b/cpp/tests/test_parameter_studies.cpp index 71bfdaae42..c3244516ae 100644 --- a/cpp/tests/test_parameter_studies.cpp +++ b/cpp/tests/test_parameter_studies.cpp @@ -25,6 +25,7 @@ #include "memilio/mobility/metapopulation_mobility_instant.h" #include "memilio/utils/random_number_generator.h" #include "utils.h" +#include "gmock/gmock.h" #include #include #include @@ -185,16 +186,20 @@ TEST(ParameterStudies, sample_graph) TEST(ParameterStudies, test_normal_distribution) { + mio::RedirectLogger logger; + mio::ParameterDistributionNormal parameter_dist_normal_1; // check if standard deviation is reduced if between too narrow interval [min,max] has to be sampled. parameter_dist_normal_1.set_upper_bound(1); parameter_dist_normal_1.set_lower_bound(-1); - parameter_dist_normal_1.log_stddev_changes(false); // only avoid warning output in tests double std_dev_demanded = parameter_dist_normal_1.get_standard_dev(); + logger.capture(); parameter_dist_normal_1.get_sample(mio::thread_local_rng()); + EXPECT_THAT(logger.read(), testing::HasSubstr("Standard deviation reduced to fit 99% of the distribution")); + logger.release(); EXPECT_GE(std_dev_demanded, parameter_dist_normal_1.get_standard_dev()); // check if full argument constructor works correctly @@ -211,7 +216,6 @@ TEST(ParameterStudies, test_normal_distribution) parameter_dist_normal_2.set_standard_dev(1.5); parameter_dist_normal_2.set_lower_bound(1); parameter_dist_normal_2.set_upper_bound(10); - parameter_dist_normal_2.log_stddev_changes(false); // only avoid warning output in tests std_dev_demanded = parameter_dist_normal_2.get_standard_dev(); parameter_dist_normal_2.check_quantiles(); @@ -226,7 +230,10 @@ TEST(ParameterStudies, test_normal_distribution) //degenerate case: ub == lb //For MSVC the normal distribution cannot have a value of 0.0 for sigma mio::ParameterDistributionNormal dist3(0.999999999 * 3.0, 1.000000001 * 3.0, 3.0, 0.00000001); + logger.capture(); EXPECT_NEAR(dist3.get_sample(mio::thread_local_rng()), 3.0, 1e-07); + EXPECT_THAT(logger.read(), testing::HasSubstr("Not successfully sampled within [min,max].")); + logger.release(); } TEST(ParameterStudies, test_uniform_distribution) @@ -368,10 +375,10 @@ TEST(ParameterStudies, check_ensemble_run_result) mio::osecir::set_params_distributions_normal(model, t0, tmax, 0.2); mio::ParameterStudy parameter_study(model, t0, tmax, 0.1, 1); - mio::log_rng_seeds(parameter_study.get_rng(), mio::LogLevel::warn); // Run parameter study auto ensemble_results = parameter_study.run_serial([](auto&& model_, auto t0_, auto dt_, auto) { + mio::LogLevelOverride llo(mio::LogLevel::off); auto copy = model_; draw_sample(copy); return mio::osecir::Simulation(copy, t0_, dt_); diff --git a/cpp/tests/test_save_results.cpp b/cpp/tests/test_save_results.cpp index ee0b2231d3..b48e72e1d3 100644 --- a/cpp/tests/test_save_results.cpp +++ b/cpp/tests/test_save_results.cpp @@ -27,6 +27,7 @@ #include "memilio/utils/time_series.h" #include "ode_secir/parameter_space.h" #include "ode_secir/parameters_io.h" +#include "utils.h" #include #include @@ -229,12 +230,11 @@ TEST(TestSaveResult, save_result_with_params) TEST(TestSaveResult, save_result_order) { - std::vector> results{ - mio::TimeSeries(0, Eigen::VectorX::Constant(1, 0)), - mio::TimeSeries(0, Eigen::VectorX::Constant(1, 1)), - mio::TimeSeries(0, Eigen::VectorX::Constant(1, 2))}; + std::vector> results{mio::TimeSeries(0, Eigen::VectorX::Constant(1, 0)), + mio::TimeSeries(0, Eigen::VectorX::Constant(1, 1)), + mio::TimeSeries(0, Eigen::VectorX::Constant(1, 2))}; - // case: check order of results, where lexical ordering would rearrange the results; + // case: check order of results, where lexical ordering would rearrange the results; // expect: order follows the ids std::vector ids = {1, 2, 10}; @@ -250,7 +250,7 @@ TEST(TestSaveResult, save_result_order) ASSERT_DOUBLE_EQ(results_from_file.value()[1].get_groups()[Eigen::Index(0)][Eigen::Index(0)], 1); ASSERT_DOUBLE_EQ(results_from_file.value()[2].get_groups()[Eigen::Index(0)][Eigen::Index(0)], 2); - // case: check order of results; + // case: check order of results; // expect: order is changed due to ids not increasing ids = {1, 10, 2}; @@ -346,7 +346,6 @@ TEST(TestSaveResult, save_percentiles_and_sums) auto num_runs = 3; mio::ParameterStudy parameter_study(graph, 0.0, 2.0, 0.5, num_runs); - mio::log_rng_seeds(parameter_study.get_rng(), mio::LogLevel::warn); TempFileRegister tmp_file_register; std::string tmp_results_dir = tmp_file_register.get_unique_path(); @@ -360,6 +359,7 @@ TEST(TestSaveResult, save_percentiles_and_sums) ensemble_edges.reserve(size_t(num_runs)); parameter_study.run( [](auto&& g, auto t0_, auto dt_, auto) { + mio::LogLevelOverride llo(mio::LogLevel::off); auto copy = g; return mio::make_sampled_graph_simulation>(draw_sample(copy), t0_, dt_, dt_); From c6bbf37d1fdb621a3abcd03231f013ac789ca977 Mon Sep 17 00:00:00 2001 From: reneSchm <49305466+reneSchm@users.noreply.github.com> Date: Thu, 18 Dec 2025 20:27:57 +0100 Subject: [PATCH 3/4] it surely is annoying that microsoft keeps doing nonstandard stuff requiring silly workarounds --- cpp/tests/test_graph.cpp | 3 ++- cpp/tests/test_utils.cpp | 6 +++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/cpp/tests/test_graph.cpp b/cpp/tests/test_graph.cpp index 7232ad0949..4dd4aaace8 100644 --- a/cpp/tests/test_graph.cpp +++ b/cpp/tests/test_graph.cpp @@ -37,6 +37,7 @@ #include "memilio/utils/stl_util.h" #include "utils.h" #include "gmock/gmock-matchers.h" +#include "gmock/gmock.h" #include #include #include @@ -378,7 +379,7 @@ TEST(TestGraphBuilder, Build_unique) mio::RedirectLogger logger; logger.capture(); auto g = std::move(builder).build(true); - EXPECT_THAT(logger.read(), testing::EndsWith("[warning] Removed duplicate edge(s)\n")); + EXPECT_THAT(logger.read(), testing::HasSubstr("[warning] Removed duplicate edge(s)")); logger.release(); EXPECT_EQ(g.nodes().size(), 3); diff --git a/cpp/tests/test_utils.cpp b/cpp/tests/test_utils.cpp index fee45638ab..fdd5b6e00c 100644 --- a/cpp/tests/test_utils.cpp +++ b/cpp/tests/test_utils.cpp @@ -171,7 +171,7 @@ TEST(TestUtils, LogLevelOverride) logger.capture(); // sanity check that the capture works (ignoring the time stamp at the start) mio::log_warning("Test0"); - EXPECT_THAT(logger.read(), testing::EndsWith("[redirect] [warning] Test0\n")); + EXPECT_THAT(logger.read(), testing::HasSubstr("[redirect] [warning] Test0")); // case: override to higher level, log at normal level; expect a usually emitted log to be ignored { mio::LogLevelOverride llo(mio::LogLevel::critical); @@ -180,13 +180,13 @@ TEST(TestUtils, LogLevelOverride) EXPECT_TRUE(logger.read().empty()); // case: log at normal level, after higher level override; expect normal logging mio::log_warning("Test2"); - EXPECT_THAT(logger.read(), testing::EndsWith("[redirect] [warning] Test2\n")); + EXPECT_THAT(logger.read(), testing::HasSubstr("[redirect] [warning] Test2")); // case: override to lower level, log at a level below normal; expect a usually ignored log to be emitted { mio::LogLevelOverride llo(mio::LogLevel::info); mio::log_info("Test3"); } - EXPECT_THAT(logger.read(), testing::EndsWith("[redirect] [info] Test3\n")); + EXPECT_THAT(logger.read(), testing::HasSubstr("[redirect] [info] Test3")); logger.release(); } From b55e81320f6d301df1f16865736fb2fa7f08411e Mon Sep 17 00:00:00 2001 From: reneSchm <49305466+reneSchm@users.noreply.github.com> Date: Fri, 19 Dec 2025 14:18:14 +0100 Subject: [PATCH 4/4] silence more errors --- cpp/tests/test_graph_abm.cpp | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/cpp/tests/test_graph_abm.cpp b/cpp/tests/test_graph_abm.cpp index be82349cf5..bb546717e8 100644 --- a/cpp/tests/test_graph_abm.cpp +++ b/cpp/tests/test_graph_abm.cpp @@ -29,13 +29,10 @@ #include "graph_abm/graph_abm_mobility.h" #include "memilio/epidemiology/age_group.h" #include "memilio/utils/logging.h" -#include "memilio/utils/miompi.h" #include "memilio/mobility/graph.h" -#include "abm_helpers.h" -#include -#include +#include "utils.h" + #include -#include struct MockHistory { @@ -253,10 +250,15 @@ TEST(TestGraphABM, test_get_person) auto& p1 = model.get_person(pid1); EXPECT_EQ(p1.get_location(), home); EXPECT_EQ(p1.get_age(), mio::AgeGroup(0)); - model.remove_person(model.get_person_index(pid1)); - EXPECT_EQ(model.get_person_index(pid1), std::numeric_limits::max()); - auto& p2 = model.get_person(pid2); - EXPECT_EQ(p2.get_location(), work); - EXPECT_EQ(p2.get_age(), mio::AgeGroup(1)); + { + model.remove_person(model.get_person_index(pid1)); + + mio::LogLevelOverride llo(mio::LogLevel::off); + EXPECT_EQ(model.get_person_index(pid1), std::numeric_limits::max()); + + auto& p2 = model.get_person(pid2); + EXPECT_EQ(p2.get_location(), work); + EXPECT_EQ(p2.get_age(), mio::AgeGroup(1)); + } }