Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
faffe9d721006b007851e2317e8c1e28f4f8c049
[simgrid.git] / src / xbt / random_test.cpp
1 /* Copyright (c) 2019. The SimGrid Team. All rights reserved.               */
2
3 /* This program is free software; you can redistribute it and/or modify it
4  * under the terms of the license (GNU LGPL) which comes with this package. */
5
6 #include "src/include/catch.hpp"
7 #include "xbt/log.h"
8 #include "xbt/random.hpp"
9
10 TEST_CASE("xbt::random: Random Number Generation")
11 {
12   SECTION("Random")
13   {
14     simgrid::xbt::random::set_mersenne_seed(12345);
15
16     REQUIRE(simgrid::xbt::random::exponential(25) == 0.00291934351538427348);
17     REQUIRE(simgrid::xbt::random::uniform_int(1, 6) == 6);
18     REQUIRE(simgrid::xbt::random::uniform_real(0, 1) == 0.31637556043369124970);
19     REQUIRE(simgrid::xbt::random::normal(0, 2) == 1.62746784745133976635);
20   }
21 }