GCC Code Coverage Report


Directory: ./
File: unittest/random_generator.hpp
Date: 2025-05-13 10:30:51
Exec Total Coverage
Lines: 0 8 0.0%
Branches: 0 16 0.0%

Line Branch Exec Source
1 ///////////////////////////////////////////////////////////////////////////////
2 // BSD 3-Clause License
3 //
4 // Copyright (C) 2019-2021, LAAS-CNRS, University of Edinburgh
5 // Copyright note valid unless otherwise stated in individual files.
6 // All rights reserved.
7 ///////////////////////////////////////////////////////////////////////////////
8
9 #ifndef CROCODDYL_RANDOM_GENERATOR_HPP_
10 #define CROCODDYL_RANDOM_GENERATOR_HPP_
11
12 #include <functional>
13 #include <random>
14
15 static std::mt19937 rng;
16
17 namespace crocoddyl {
18 namespace unittest {
19
20 template <typename IntType>
21 IntType random_int_in_range(IntType first = 0, IntType last = 10) {
22 return std::uniform_int_distribution<IntType>(first, last)(rng);
23 }
24
25 template <typename RealType>
26 RealType random_real_in_range(RealType first = 0, RealType last = 1) {
27 return std::uniform_real_distribution<RealType>(first, last)(rng);
28 }
29
30 bool random_boolean() {
31 static auto generator = std::bind(std::uniform_int_distribution<>(0, 1),
32 std::default_random_engine());
33 return generator();
34 }
35
36 } // namespace unittest
37 } // namespace crocoddyl
38
39 #endif // CROCODDYL_RANDOM_GENERATOR_HPP_
40