From c34969e89c1e480aaab7d7fb40fdfe025e30a30d Mon Sep 17 00:00:00 2001 From: Yann Duplouy Date: Mon, 27 Apr 2020 10:02:12 +0200 Subject: [PATCH] Tests whether the file could be opened and removes the temporary file at the end --- src/xbt/random_test.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/xbt/random_test.cpp b/src/xbt/random_test.cpp index a18ec233b2..9b66134836 100644 --- a/src/xbt/random_test.cpp +++ b/src/xbt/random_test.cpp @@ -47,11 +47,16 @@ TEST_CASE("xbt::random: Random Number Generation") simgrid::xbt::random::set_mersenne_seed(12345); simgrid::xbt::random::exponential(25); - simgrid::xbt::random::write_mersenne_state("rdm_state_tmp.txt"); + bool writtenA = simgrid::xbt::random::write_mersenne_state("rdm_state_tmp.txt"); double resB = simgrid::xbt::random::uniform_real(10, 20); double resC = simgrid::xbt::random::normal(0, 2); - simgrid::xbt::random::read_mersenne_state("rdm_state_tmp.txt"); + bool writtenB = simgrid::xbt::random::read_mersenne_state("rdm_state_tmp.txt"); + REQUIRE(writtenA); + REQUIRE(writtenB); REQUIRE_THAT(simgrid::xbt::random::uniform_real(10, 20), EpsilonApprox(resB)); REQUIRE_THAT(simgrid::xbt::random::normal(0, 2), EpsilonApprox(resC)); + if (writtenB) { + std::remove("rdm_state_tmp.txt"); + } } } -- 2.20.1