MRPT  1.9.9
random_unittest.cpp
Go to the documentation of this file.
1 /* +------------------------------------------------------------------------+
2  | Mobile Robot Programming Toolkit (MRPT) |
3  | http://www.mrpt.org/ |
4  | |
5  | Copyright (c) 2005-2018, Individual contributors, see AUTHORS file |
6  | See: http://www.mrpt.org/Authors - All rights reserved. |
7  | Released under BSD License. See details in http://www.mrpt.org/License |
8  +------------------------------------------------------------------------+ */
9 
11 #include <gtest/gtest.h>
12 
13 TEST(Random, Randomize)
14 {
15  using namespace mrpt::random;
16 
17  CRandomGenerator rnd;
18  rnd.randomize(1);
19  auto r1a = rnd.drawUniform32bit();
20  rnd.randomize(2);
21  auto r2a = rnd.drawUniform32bit();
22 
23  EXPECT_NE(r1a, r2a);
24 
25  rnd.randomize(1);
26  auto r1abis = rnd.drawUniform32bit();
27  EXPECT_EQ(r1a, r1abis);
28 }
A namespace of pseudo-random numbers generators of diferent distributions.
uint32_t drawUniform32bit()
Generate a uniformly distributed pseudo-random number using the MT19937 algorithm, in the whole range of 32-bit integers.
void randomize(const uint32_t seed)
Initialize the PRNG from the given random seed.
A thred-safe pseudo random number generator, based on an internal MT19937 randomness generator...
void Randomize(const uint32_t seed)
Randomize the generators.
TEST(Random, Randomize)



Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: 7d5e6d718 Fri Aug 24 01:51:28 2018 +0200 at lun nov 2 08:35:50 CET 2020