+
+ SECTION("One stochastic event (parsing)")
+ {
+ using simgrid::kernel::profile::Distribution;
+ std::vector<simgrid::kernel::profile::StochasticDatedValue> got = trace2selist("STOCHASTIC\n"
+ "DET 0 UNIF 10 20");
+
+ std::vector<simgrid::kernel::profile::StochasticDatedValue> want;
+ want.emplace_back(Distribution::DET, std::vector<double>{0}, Distribution::UNIF, std::vector<double>{10, 20});
+
+ REQUIRE(want == got);
+ }
+
+ SECTION("Several stochastic events (all possible parsing forms)")
+ {
+ using simgrid::kernel::profile::Distribution;
+ std::vector<simgrid::kernel::profile::StochasticDatedValue> got = trace2selist("STOCHASTIC\n"
+ "DET 0 DET 4\n"
+ "NORMAL 25 10 DET 3\n"
+ "UNIF 10 20 NORMAL 25 10\n"
+ "DET 5 UNIF 5 25");
+
+ std::vector<simgrid::kernel::profile::StochasticDatedValue> want;
+ want.emplace_back(Distribution::DET, std::vector<double>{0}, Distribution::DET, std::vector<double>{4});
+ want.emplace_back(Distribution::NORM, std::vector<double>{25, 10}, Distribution::DET, std::vector<double>{3});
+ want.emplace_back(Distribution::UNIF, std::vector<double>{10, 20}, Distribution::NORM, std::vector<double>{25, 10});
+ want.emplace_back(Distribution::DET, std::vector<double>{5}, Distribution::UNIF, std::vector<double>{5, 25});
+
+ REQUIRE(want == got);
+ }
+
+ SECTION("Two stochastic events (drawing each distribution)")
+ {
+ simgrid::xbt::random::set_implem_xbt();
+ simgrid::xbt::random::set_mersenne_seed(12345);
+ std::vector<simgrid::kernel::profile::DatedValue> got = trace2vector("STOCHASTIC\n"
+ "DET 0 UNIF 10 20\n"
+ "EXP 0.05 NORMAL 15 5");
+
+ std::vector<simgrid::kernel::profile::DatedValue> want;
+ // The following values were drawn using the XBT_RNG_xbt method /outside/ the testcase.
+ want.emplace_back(0, 19.29616086867082813683);
+ want.emplace_back(2.32719992449416279712, 20.16807234800742065772);
+
+ REQUIRE(want == got);
+ }
+
+ SECTION("Two stochastic events, with a loop")
+ {
+ simgrid::xbt::random::set_implem_xbt();
+ simgrid::xbt::random::set_mersenne_seed(12345);
+ std::vector<simgrid::kernel::profile::DatedValue> got = trace2vector("STOCHASTIC LOOP\n"
+ "DET 0 UNIF 10 20\n"
+ "EXP 0.05 NORMAL 15 5\n"
+ "UNIF 1 2 DET 0");
+
+ // In this case, the main use of the last stochastic event is to set when the first event takes place.
+
+ std::vector<simgrid::kernel::profile::DatedValue> want;
+ want.emplace_back(0, 19.29616086867082813683);
+ want.emplace_back(2.32719992449416279712, 20.16807234800742065772);
+ want.emplace_back(3.51111873684917075167, 0);
+ want.emplace_back(3.51111873684917075167, 10.39759496468994726115);
+
+ REQUIRE(want == got);
+ }