diff options
| author | Martin Hořeňovský | 2023-12-10 12:10:19 +0100 |
|---|---|---|
| committer | Martin Hořeňovský | 2023-12-10 19:53:41 +0100 |
| commit | 28c66fdc5a7329aaad33db611944b832564af4d3 (patch) | |
| tree | cf3962c796ca91ce243ce27c97c6cc80a795717e /src/catch2 | |
| parent | ed9d672b5ced5647d8420f3b4d040199a3281a2b (diff) | |
| download | catch3-28c66fdc5a7329aaad33db611944b832564af4d3.tar.gz | |
Make uniform_floating_point_distribution reproducible
By moving to use our `uniform_integer_distribution`, which is
reproducible across different platforms, instead of the stdlib
one which is not, we can provide reproducible results for `float`s
and `double`s. Still no reproducibility for `long double`s, because
those are too different across different platforms.
Diffstat (limited to 'src/catch2')
| -rw-r--r-- | src/catch2/internal/catch_uniform_floating_point_distribution.hpp | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/src/catch2/internal/catch_uniform_floating_point_distribution.hpp b/src/catch2/internal/catch_uniform_floating_point_distribution.hpp index 9a52bcc7..a1cdfe43 100644 --- a/src/catch2/internal/catch_uniform_floating_point_distribution.hpp +++ b/src/catch2/internal/catch_uniform_floating_point_distribution.hpp @@ -10,10 +10,10 @@ #define CATCH_UNIFORM_FLOATING_POINT_DISTRIBUTION_HPP_INCLUDED #include <catch2/internal/catch_random_floating_point_helpers.hpp> +#include <catch2/internal/catch_uniform_integer_distribution.hpp> #include <cmath> #include <type_traits> -#include <random> namespace Catch { @@ -76,8 +76,7 @@ class uniform_floating_point_distribution { FloatType m_a, m_b; FloatType m_ulp_magnitude; WidthType m_floats_in_range; - // TODO: we want to eventually replace this distribution with our own for reproducibility - std::uniform_int_distribution<WidthType> m_int_dist; + uniform_integer_distribution<WidthType> m_int_dist; // In specific cases, we can overflow into `inf` when computing the // `steps * g` offset. To avoid this, we don't offset by more than this |